malloc: Trim unused arenas on thread exit
Florian Weimer
fweimer@redhat.com
Wed Nov 15 14:35:00 GMT 2017
On 11/15/2017 03:17 PM, Siddhesh Poyarekar wrote:
> On Wednesday 15 November 2017 07:40 PM, Florian Weimer wrote:
>>
>> I assumed the comment was sufficient:
>>
>>>> Â static void __attribute__ ((section ("__libc_thread_freeres_fn")))
>>>> Â arena_thread_freeres (void)
>>>> Â {
>>>> + /* Shut down the thread cache first. This could deallocate data for
>>>> +Â Â Â Â the thread arena, so do this before we put the arena on the free
>>>> +    list. */
>>>> +Â tcache_thread_shutdown ();
>>
>> If it is not, we need to put more documentation in the code itself.
>
> The comment describes the current behaviour while the commit log should
> describe the change, something like:
>
> "Call tcache destructor in arena_thread_freeres
>
> Having separate cleanup functions for arena and tcache could result in
> the tcache freeres function being called later and thus not deallocate
> data for the thread arena. Avoid this by calling the tcache cleanup
> function from within arena_thread_freeres."
But I have not verified that this actually happens, and we agreed that
it was a good change nevertheless.
Thanks,
Florian
More information about the Libc-alpha
mailing list