Promptly freeing the per-thread cached direct buffers when a thread exits

David Lloyd david.lloyd at redhat.com
Fri Apr 6 16:15:29 UTC 2018


On Fri, Apr 6, 2018 at 8:57 AM, Tony Printezis <tprintezis at twitter.com> wrote:
>> ThreadLocal clearing
>
> Could you clarify what you mean by ThreadLocal clearing?

I mean calling ThreadLocal#remove().

> I like the suggestion to add an overridable exit() method to ThreadLocal. If
> you want to avoid calling user code by Thread::exit, would adding
> ThreadLocals (which are tagged appropriately) to a queue for later
> processing a better approach (similar to the mechanism used for References /
> ReferencesQueues)? The user can of course create a memory leak by not
> polling the queue frequently enough. But, that’s also the case for
> References. And at least user code cannot block Thread::exit.

It's more complexity, and at some point you have to ask: is it better
to block thread A or thread B?  At least blocking thread A is somewhat
expected.

-- 
- DML


More information about the core-libs-dev mailing list