mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 15:09:31 +03:00
do not reclaim segments on collect
This commit is contained in:
parent
76e727f7d1
commit
12701b1aac
1 changed files with 13 additions and 18 deletions
31
src/heap.c
31
src/heap.c
|
@ -114,26 +114,21 @@ static void mi_heap_collect_ex(mi_heap_t* heap, mi_collect_t collect)
|
||||||
if (!mi_heap_is_initialized(heap)) return;
|
if (!mi_heap_is_initialized(heap)) return;
|
||||||
_mi_deferred_free(heap, collect >= MI_FORCE);
|
_mi_deferred_free(heap, collect >= MI_FORCE);
|
||||||
|
|
||||||
// collect (some) abandoned pages
|
// note: never reclaim on collect but leave it to threads that need storage to reclaim
|
||||||
if (collect >= MI_NORMAL && !heap->no_reclaim) {
|
if (
|
||||||
if (collect == MI_NORMAL) {
|
#ifdef NDEBUG
|
||||||
// this may free some segments (but also take ownership of abandoned pages)
|
collect == MI_FORCE
|
||||||
_mi_segment_try_reclaim_abandoned(heap, false, &heap->tld->segments);
|
#else
|
||||||
}
|
collect >= MI_FORCE
|
||||||
else if (
|
#endif
|
||||||
#ifdef NDEBUG
|
&& _mi_is_main_thread() && mi_heap_is_backing(heap) && !heap->no_reclaim)
|
||||||
collect == MI_FORCE
|
{
|
||||||
#else
|
// the main thread is abandoned (end-of-program), try to reclaim all abandoned segments.
|
||||||
collect >= MI_FORCE
|
// if all memory is freed by now, all segments should be freed.
|
||||||
#endif
|
_mi_segment_try_reclaim_abandoned(heap, true, &heap->tld->segments);
|
||||||
&& _mi_is_main_thread() && mi_heap_is_backing(heap))
|
|
||||||
{
|
|
||||||
// the main thread is abandoned (end-of-program), try to reclaim all abandoned segments.
|
|
||||||
// if all memory is freed by now, all segments should be freed.
|
|
||||||
_mi_segment_try_reclaim_abandoned(heap, true, &heap->tld->segments);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if abandoning, mark all pages to no longer add to delayed_free
|
// if abandoning, mark all pages to no longer add to delayed_free
|
||||||
if (collect == MI_ABANDON) {
|
if (collect == MI_ABANDON) {
|
||||||
mi_heap_visit_pages(heap, &mi_heap_page_never_delayed_free, NULL, NULL);
|
mi_heap_visit_pages(heap, &mi_heap_page_never_delayed_free, NULL, NULL);
|
||||||
|
|
Loading…
Add table
Reference in a new issue