Conversation

Replying to
MEM_RELEASE will free the mapping completely like munmap on Linux, making the address space usable for other things. MEM_DECOMMIT will release the memory but hold onto the reserve address space like clobbering a mapping with mmap + MAP_FIXED + PROT_NONE on Linux.
2
2
Replying to
What does "hold onto" mean in this context? Does it mean the process continues to reserve the memory but the content pages are discarded?
1
1
Replying to and
Linux has a memory accounting mode via /proc/sys/vm/overcommit_memory and it just treats fresh PROT_NONE mappings the way Windows does MEM_RESERVE mappings. Not really a way to do MEM_DECOMMIT on Linux other than clobbering with a new PROT_NONE mapping via mmap with MAP_FIXED.
2
2
Replying to and
If you purge all the pages from it on Linux with madvise + MADV_DONTNEED and then mprotect it back to PROT_NONE, the kernel still counts it against you for memory accounting. Have to clobber it with a fresh mapping to get a MEM_DECOMMIT equivalent which works fine but is odd.