mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-25 20:14:12 +08:00
ensure we dont reclaim a segment on a free if that would go above the target segment count
This commit is contained in:
parent
3f3aee918a
commit
4f46cf7d5a
@ -1261,6 +1261,8 @@ bool _mi_segment_attempt_reclaim(mi_heap_t* heap, mi_segment_t* segment) {
|
||||
if (mi_atomic_load_relaxed(&segment->thread_id) != 0) return false; // it is not abandoned
|
||||
if (segment->subproc != heap->tld->segments.subproc) return false; // only reclaim within the same subprocess
|
||||
if (!_mi_heap_memid_is_suitable(heap,segment->memid)) return false; // don't reclaim between exclusive and non-exclusive arena's
|
||||
const long target = _mi_option_get_fast(mi_option_target_segments_per_thread);
|
||||
if (target > 0 && (size_t)target <= heap->tld->segments.count) return false; // don't reclaim if going above the target count
|
||||
// don't reclaim more from a `free` call than half the current segments
|
||||
// this is to prevent a pure free-ing thread to start owning too many segments
|
||||
// (but not for out-of-arena segments as that is the main way to be reclaimed for those)
|
||||
|
Loading…
x
Reference in New Issue
Block a user