Details
-
Technical task
-
Resolution: Done
-
P3: Somewhat important
-
None
-
None
Description
In our garbage collector it may happen that a memory chunk cannot be decommitted entirely because for example one persistent JS object prevents us. However we could still decommit the page ranges in the chunk that are free (MADV_DONTNEED) on operating systems (Linux, Windows) where we know for sure that subsequent page access will see zeroed pages.
The use of MADV_DONTNEED will preserve the address space reservation, but it does allow for the underlying pages to be released. That can be a good strategy to reduce the overhead of fragmentation. malloc_trim() in glibc apparently deploys the same strategy for the C runtime heap.