4 ms·
Memory allocators for manual memory management could return memory asynchronously in a separate thread as well. The call to free() is only required to update s
by scott_s 7y ago
Memory allocators for manual memory management could return memory asynchronously in a separate thread as well. The call to free() is only required to update some internal bookkeeping in the memory allocator's internal data structures. A separate thread could easily monitor when the data structures that hold raw pages from the OS are completely free, and return them to the OS.
- thedance 7y agoThat's what tcmalloc does, at least if you set TCMALLOC_RELEASE_RATE.
- scott_s 7y agoI don't think that's completely true. The value TCMALLOC_RELEASE_RATE controls how often tcmalloc returns memory back to the OS, but I don't believe it uses a separate thread for that task.
- thedance 7y agoHrmm, you’re right. This seems to be among the gratuitous differences between internal and open source tcmalloc.
- alexhutcheson 7y agoHave you seen the recently updated GitHub project: https://github.com/google/tcmalloc https://github.com/google/tcmalloc