microsoft / snmalloc

Message passing based allocator
MIT License
1.57k stars 106 forks source link

allocator purge exposure ? #436

Open devnexen opened 2 years ago

devnexen commented 2 years ago

jemalloc provides the ability to purge a specific arena via mallctl with the oid 'arena.[id].purge', so I was wondering if the feature closest to it would be LocalAllocator::flush() (or literally teardown in the upper level) and it was a good idea to expose such capability as C symbol ?

mjp41 commented 2 years ago

The nearest bit is https://github.com/microsoft/snmalloc/blob/b1da339b3e57fe8fdf5dc2a3c0cb30fb2ea993c2/src/mem/chunkallocator.h#L147-L178 This on a timer pushes unused chunks of memory back into central pools and decommits them.

I want to get LowMemory notifications to call a modified version of this.

Your question makes me think that teardown should also interact with this code, and I don't think it currently does. I am deep in a concurrency issue on Verona at a moment, but can think this through tomorrow.