Returning a dirty arena with MADV_FREE

A custom allocator returns a 512 MiB arena to the kernel. Every page of the arena is private anonymous memory that was written earlier. The allocator calls madvise(MADV_FREE) on it instead of MADV_DONTNEED, to avoid the cost of zero-filling pages it may reuse later. The machine has tens of gigabytes of free RAM. A few minutes later, monitoring reads the process's RSS, and the program then reads one byte from the arena without writing to it first. What do the RSS and the byte read look like?

arena.cpp
#include <sys/mman.h>

void release_arena(char* arena, size_t len) {
    // every page in [arena, arena + len) was written before this call
    madvise(arena, len, MADV_FREE);
}

// ... minutes later, on a machine with plenty of free memory ...
char peek(const char* arena) {
    return arena[1000 * 4096];   // read only, no write since madvise()
}

46 of 53 in Operating Systems