<div dir="ltr"><div>Hello Jason,</div><div><br></div><div>I am playing around with the memory management hooks introduced in version 4.</div><div>So I wrote a delegate for the default chunk hooks, that additionally report to</div><div>stdout what's happening [1]. </div><div><br></div><div>The test program allocates 1GB of memory and immediately frees it.</div><div>It then tries to allocate 4MB and 8MB. The output is as follows</div><div><br></div><div><div>ALLOC: new_addr 0, size 1073741824, alignment 2097152, zero 1, commit 1, arena_ind 0, ret 0x7f2f52a00000</div><div>DALLOC: chunk 0x7f2f52a00000, size 1073741824, committed 1, arena_ind 0</div><div>DECOMMIT: chunk 0x7f2f52a00000, size 1073741824, offset 0, length 1073741824, arena_ind 0</div><div>PURGE: chunk 0x7f2f52a00000, size 1073741824, offset 0, length 1073741824, arena_ind 0</div><div>FREED</div><div>ALLOC: new_addr 0, size 4194304, alignment 2097152, zero 1, commit 1, arena_ind 0, ret 0x7f2f52a00000</div><div>ALLOC: new_addr 0, size 8388608, alignment 2097152, zero 1, commit 1, arena_ind 0, ret 0x7f2f52e00000</div></div><div><br></div><div>Given that the 1GB has not been deallocated, but purged I would expect </div><div>the last two ALLOCations not to have happened. Instead I would expect</div><div>the virtual memory from the 1GB allocation before to be reused?</div><div><br></div><div>I am running jemalloc 4.0.4 on Linux.</div><div><br></div><div>Also, on an unrelated note, is it generally safe to trigger purging for arena A</div><div>from within an allocation chunk hook of arena B, with A <> B? </div><div>The reason why am asking this question is that I would generally want to </div><div>run with purging disabled on all arenas, but if some threshold of committed </div><div>memory is surpassed I would like to enable purging for some arenas. </div><div>Does this sound feasible?</div><div><br></div><div>Thanks,</div><div>Jakob</div><div><br></div>[1] <a href="https://gist.github.com/buchgr/243b0aa9a2abeda2ac39">https://gist.github.com/buchgr/243b0aa9a2abeda2ac39</a>
<div><br></div></div>