mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-08 16:29:31 +03:00
merge from dev3
This commit is contained in:
commit
16574468d6
2 changed files with 5 additions and 13 deletions
|
@ -123,7 +123,7 @@ static void mi_heap_collect_ex(mi_heap_t* heap, mi_collect_t collect)
|
||||||
|
|
||||||
// collect arenas (this is program wide so don't force purges on abandonment of threads)
|
// collect arenas (this is program wide so don't force purges on abandonment of threads)
|
||||||
//mi_atomic_storei64_release(&heap->tld->subproc->purge_expire, 1);
|
//mi_atomic_storei64_release(&heap->tld->subproc->purge_expire, 1);
|
||||||
_mi_arenas_collect(collect == MI_FORCE /* force purge? */, true /* visit all? */, heap->tld);
|
_mi_arenas_collect(collect == MI_FORCE /* force purge? */, collect >= MI_FORCE /* visit all? */, heap->tld);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _mi_heap_collect_abandon(mi_heap_t* heap) {
|
void _mi_heap_collect_abandon(mi_heap_t* heap) {
|
||||||
|
|
16
src/page.c
16
src/page.c
|
@ -436,7 +436,7 @@ void _mi_heap_collect_retired(mi_heap_t* heap, bool force) {
|
||||||
heap->page_retired_max = max;
|
heap->page_retired_max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static void mi_heap_collect_full_pages(mi_heap_t* heap) {
|
static void mi_heap_collect_full_pages(mi_heap_t* heap) {
|
||||||
// note: normally full pages get immediately abandoned and the full queue is always empty
|
// note: normally full pages get immediately abandoned and the full queue is always empty
|
||||||
// this path is only used if abandoning is disabled due to a destroy-able heap or options
|
// this path is only used if abandoning is disabled due to a destroy-able heap or options
|
||||||
|
@ -457,15 +457,8 @@ static void mi_heap_collect_full_pages(mi_heap_t* heap) {
|
||||||
page = next;
|
page = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static mi_decl_noinline void mi_heap_generic_collect(mi_heap_t* heap) {
|
|
||||||
// call potential deferred free routines
|
|
||||||
_mi_deferred_free(heap, false);
|
|
||||||
// collect retired pages
|
|
||||||
_mi_heap_collect_retired(heap, false);
|
|
||||||
// collect full pages that had concurrent free's
|
|
||||||
mi_heap_collect_full_pages(heap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------
|
/* -----------------------------------------------------------
|
||||||
Initialize the initial free list in a page.
|
Initialize the initial free list in a page.
|
||||||
|
@ -921,14 +914,13 @@ void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_al
|
||||||
// collect every N generic mallocs
|
// collect every N generic mallocs
|
||||||
if mi_unlikely(heap->generic_count++ > 10000) {
|
if mi_unlikely(heap->generic_count++ > 10000) {
|
||||||
heap->generic_count = 0;
|
heap->generic_count = 0;
|
||||||
mi_heap_generic_collect(heap);
|
mi_heap_collect(heap, false /* force? */);
|
||||||
}
|
}
|
||||||
|
|
||||||
// find (or allocate) a page of the right size
|
// find (or allocate) a page of the right size
|
||||||
mi_page_t* page = mi_find_page(heap, size, huge_alignment);
|
mi_page_t* page = mi_find_page(heap, size, huge_alignment);
|
||||||
if mi_unlikely(page == NULL) { // first time out of memory, try to collect and retry the allocation once more
|
if mi_unlikely(page == NULL) { // first time out of memory, try to collect and retry the allocation once more
|
||||||
mi_heap_generic_collect(heap);
|
mi_heap_collect(heap, true /* force? */);
|
||||||
mi_heap_collect(heap, true /* force */);
|
|
||||||
page = mi_find_page(heap, size, huge_alignment);
|
page = mi_find_page(heap, size, huge_alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue