This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc: Trim unused arenas on thread exit


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."

Siddhesh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]