Purgeable Memory Allocations for Linux
https://nullprogram.com/blog/2019/12/29/ [nullprogram.com]
2019-12-30 23:29
It allocates anonymous pages using mmap(2). When the allocation is “unlocked” — i.e. the process isn’t actively using it — its pages are marked with MADV_FREE so that the kernel can reclaim them at any time. To lock the allocation so that the process can safely make use of them, the MADV_FREE is canceled. This is all a little trickier than it sounds, and that’s the subject of this article.