[PATCH] malloc: retire mechanism for older non used tcached chunks
Florian Weimer
fweimer@redhat.com
Thu Nov 13 16:04:19 GMT 2025
* Cupertino Miranda:
>>> + while (tcache_tmp->return_to_arena)
>>> + {
>>> + tcache_entry *e = tcache_tmp->return_to_arena;
>>> + if (__glibc_unlikely (misaligned_mem (e)))
>>> + malloc_printerr ("tcache_thread_shutdown(): "
>>> + "unaligned tcache chunk detected");
>>> + tcache_tmp->return_to_arena = REVEAL_PTR (e->next);
>>> + __libc_free (e);
>> These needs a comment why this actually returns allocations to the
>> arena. And if it doesn't why this isn't necessary.
> I don't know if I understand what you mean. It always does it in that
> loop, right? The loop traverses the bin freeing all those chunks.
> One mistake I notice there is the call to __libc_free, instead of
> _int_free_chunk, locking the arena only once instead of for each
> chunk.
Well, that's what I meant. 8-)
I haven't done an in-depth review of the patch, and I may not have time
soon to look into it further.
Thanks,
Florian
More information about the Libc-alpha
mailing list