fix: avoid unnecessary page allocation
When import objects deleted by other threads, we may add elements to `p` free list.
This commit is contained in:
parent
6dd3616298
commit
dfd1f23030
1 changed files with 4 additions and 1 deletions
|
|
@ -370,7 +370,10 @@ extern "C" void * lean_alloc_small(unsigned sz, unsigned slot_idx) {
|
|||
if (LEAN_UNLIKELY(r == nullptr)) {
|
||||
if (g_heap->m_page_free_list[slot_idx] == nullptr) {
|
||||
g_heap->import_objs();
|
||||
p = alloc_page(g_heap, sz);
|
||||
lean_assert(g_heap->m_curr_page[slot_idx] == p);
|
||||
/* g_heap->import_objs() may add objects to p->m_header.m_free_list */
|
||||
if (p->m_header.m_free_list == nullptr)
|
||||
p = alloc_page(g_heap, sz);
|
||||
} else {
|
||||
p = page_list_pop(g_heap->m_page_free_list[slot_idx]);
|
||||
p->m_header.m_in_page_free_list = false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue