mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-01 09:14:38 +03:00
skip purge after arenas destroy
This commit is contained in:
parent
aaf8da9aba
commit
1b5ee4e2d0
1 changed files with 5 additions and 7 deletions
12
src/arena.c
12
src/arena.c
|
@ -1088,9 +1088,8 @@ bool _mi_arenas_contain(const void* p) {
|
|||
// for dynamic libraries that are unloaded and need to release all their allocated memory.
|
||||
static void mi_arenas_unsafe_destroy(mi_subproc_t* subproc) {
|
||||
mi_assert_internal(subproc != NULL);
|
||||
const size_t max_arena = mi_arenas_get_count(subproc);
|
||||
size_t new_max_arena = 0;
|
||||
for (size_t i = 0; i < max_arena; i++) {
|
||||
const size_t arena_count = mi_arenas_get_count(subproc);
|
||||
for (size_t i = 0; i < arena_count; i++) {
|
||||
mi_arena_t* arena = mi_atomic_load_ptr_acquire(mi_arena_t, &subproc->arenas[i]);
|
||||
if (arena != NULL) {
|
||||
// mi_lock_done(&arena->abandoned_visit_lock);
|
||||
|
@ -1100,10 +1099,9 @@ static void mi_arenas_unsafe_destroy(mi_subproc_t* subproc) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try to lower the max arena.
|
||||
size_t expected = max_arena;
|
||||
mi_atomic_cas_strong_acq_rel(&subproc->arena_count, &expected, new_max_arena);
|
||||
size_t expected = arena_count;
|
||||
mi_atomic_cas_strong_acq_rel(&subproc->arena_count, &expected, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1111,7 +1109,7 @@ static void mi_arenas_unsafe_destroy(mi_subproc_t* subproc) {
|
|||
// for dynamic libraries that are unloaded and need to release all their allocated memory.
|
||||
void _mi_arenas_unsafe_destroy_all(mi_subproc_t* subproc) {
|
||||
mi_arenas_unsafe_destroy(subproc);
|
||||
mi_arenas_try_purge(true /* force purge */, true /* visit all*/, subproc, 0 /* thread seq */); // purge non-owned arenas
|
||||
// mi_arenas_try_purge(true /* force purge */, true /* visit all*/, subproc, 0 /* thread seq */); // purge non-owned arenas
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue