I don't understand the difference between MEM_RELEASE and MEM_DECOMMIT in the Windows VirtualFree function.
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.
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
Or does it mean the process continues to reserve the memory AND the pointer but the content is invalidated?
1
1
Show replies
MEM_DECOMMIT is the same as making a fresh mapping with VirtualAlloc using MEM_RESERVE.
You go from a reserved mapping to usable memory with MEM_COMMIT like using mprotect for that purpose on Linux. Windows separates the concept of whether it's committed from protection mode.
1
1
2
Show replies

