mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
fix leak where OS abandoned blocks were not always reclaimed
This commit is contained in:
parent
00dacba91f
commit
96b69d7ef6
5 changed files with 361 additions and 291 deletions
|
@ -131,13 +131,17 @@ void* _mi_arena_meta_zalloc(size_t size, mi_memid_t* memid);
|
|||
void _mi_arena_meta_free(void* p, mi_memid_t memid, size_t size);
|
||||
|
||||
typedef struct mi_arena_field_cursor_s { // abstract struct
|
||||
size_t start;
|
||||
size_t end;
|
||||
size_t bitmap_idx;
|
||||
mi_subproc_t* subproc;
|
||||
size_t os_list_count; // max entries to visit in the OS abandoned list
|
||||
size_t start; // start arena idx (may need to be wrapped)
|
||||
size_t end; // end arena idx (exclusive, may need to be wrapped)
|
||||
size_t bitmap_idx; // current bit idx for an arena
|
||||
mi_subproc_t* subproc; // only visit blocks in this sub-process
|
||||
bool visit_all; // ensure all abandoned blocks are seen (blocking)
|
||||
bool hold_visit_lock; // if the subproc->abandoned_os_visit_lock is held
|
||||
} mi_arena_field_cursor_t;
|
||||
void _mi_arena_field_cursor_init(mi_heap_t* heap, mi_subproc_t* subproc, mi_arena_field_cursor_t* current);
|
||||
mi_segment_t* _mi_arena_segment_clear_abandoned_next(mi_arena_field_cursor_t* previous, bool visit_all);
|
||||
void _mi_arena_field_cursor_init(mi_heap_t* heap, mi_subproc_t* subproc, bool visit_all, mi_arena_field_cursor_t* current);
|
||||
mi_segment_t* _mi_arena_segment_clear_abandoned_next(mi_arena_field_cursor_t* previous);
|
||||
void _mi_arena_field_cursor_done(mi_arena_field_cursor_t* current);
|
||||
|
||||
// "segment-map.c"
|
||||
void _mi_segment_map_allocated_at(const mi_segment_t* segment);
|
||||
|
|
|
@ -613,7 +613,8 @@ void _mi_stat_counter_increase(mi_stat_counter_t* stat, size_t amount);
|
|||
struct mi_subproc_s {
|
||||
_Atomic(size_t) abandoned_count; // count of abandoned segments for this sub-process
|
||||
_Atomic(size_t) abandoned_os_list_count; // count of abandoned segments in the os-list
|
||||
mi_lock_t abandoned_os_lock; // lock for the abandoned segments outside of arena's
|
||||
mi_lock_t abandoned_os_lock; // lock for the abandoned os segment list (outside of arena's) (this lock protect list operations)
|
||||
mi_lock_t abandoned_os_visit_lock; // ensure only one thread per subproc visits the abandoned os list
|
||||
mi_segment_t* abandoned_os_list; // doubly-linked list of abandoned segments outside of arena's (in OS allocated memory)
|
||||
mi_segment_t* abandoned_os_list_tail; // the tail-end of the list
|
||||
mi_memid_t memid; // provenance of this memory block
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue