Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Restore ``mimalloc``'s previous behavior of processing delayed frees from other
threads on every generic malloc call, reverting the change introduced in v2.2.2.
9 changes: 6 additions & 3 deletions Objects/mimalloc/page.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,16 +1071,19 @@ void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_al
}
mi_assert_internal(mi_heap_is_initialized(heap));

// Process delayed frees from other threads (but skip contended ones).
// CPython: gh-161420 showed that calling _mi_heap_delayed_free_partial only
// once every 100 generic malloc calls led to high memory usage.
// To avoid this, we now process delayed frees on every generic malloc call again.
_mi_heap_delayed_free_partial(heap);

// do administrative tasks every N generic mallocs
if mi_unlikely(++heap->generic_count >= 100) {
heap->generic_collect_count += heap->generic_count;
heap->generic_count = 0;
// call potential deferred free routines
_mi_deferred_free(heap, false);

// free delayed frees from other threads (but skip contended ones)
_mi_heap_delayed_free_partial(heap);

// collect every once in a while (10000 by default)
const long generic_collect = mi_option_get_clamp(mi_option_generic_collect, 1, 1000000L);
if (heap->generic_collect_count >= generic_collect) {
Expand Down
Loading