<div dir="ltr">Hi all,<div><br></div><div>I'm writing a set of chunk_hooks that satisfy chunk_alloc requests with a bump pointer and opt out of dalloc, decommit, and purge. The goal is to back an arena with 2MB and 1GB huge pages on demand and force jemalloc to reuse the memory in that space.<br></div><div><br></div><div>I wrote a simple program to test page reuse. As pseudocode:</div><div><ol><li>malloc 1GB of memory using repeated small allocations<br></li><li>free that same 1GB<br></li><li>malloc a small amount of memory again<br></li><li>check whether jemalloc call chunk_alloc again in (3)<br></li></ol></div><div>I've noticed that when dirty page purging is disabled by setting MALLOC_CONF="lg_dirty_mult:-1", jemalloc willingly reuses all of the memory provided by my chunk hooks, but when the option is off, it only reuses about one chunk's worth (~4Mb).<br></div><div><br></div><div>I would consider this intended behavior (obviously my test program goes below the default 8:1 minimum active to free page ratio), except that the man page entry for chunk_purge_t reads</div><div><br></div><div>> A chunk purge function conforms to the chunk_purge_t type and <b>optionally</b> discards physical pages</div><div><br></div><div>I'm further confused because it seems that API for chunk_hooks_t offers no mechanism for signaling to jemalloc that the pages were not released.</div><div><br></div><div>Basically, I'm asking whether it's intended that opt.lg_dirty_mult must be set to -1 in order for jemalloc to reuse an arbitrary amount of chunk_hook-allocated memory.</div><div><br></div><div>Very best,</div><div>Benjamin</div></div>