#Should free() return memory to the OS?
15 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
yeah you can munmap when the region you allocated using mmap isn't in use anymore
If I munmap a chunk of size 32 (chunk is marked as free) and then I want to allocate more mem of size 32, how will that memory be usable if it’s munmapedz Wouldn’t it be an access violation or something?
you can only mmap and munmap full pages
Ooh okay
and munmap will unmap the entire region originally allocated by mmap
You should generally not munmap to the OS
If you have a normal allocation setup this will be either semi-expensive to compute or end up fragmenting your arenas
About the fragments, does free() bother coalescing freed chunks that are separated by unfreed chunks? Like <free(32), unfree(32), free(32), unfree(32)> -> <free(64), unfree(32), unfree(32)> ? It seems exhaustive unless it somehow doesn’t move the unfreed memory over