Promptly freeing the per-thread cached direct buffers when a thread exits
Alan Bateman
Alan.Bateman at oracle.com
Fri Apr 6 16:45:22 UTC 2018
On 06/04/2018 15:08, Tony Printezis wrote:
> Hi Alan,
>
> Calling sun.nio directly from java.lang seemed a bit dodgy to me,
> which is why I proposed some type of exit hook (maybe I overthought
> this?). But that’d be OK, could make this change a lot simpler. :-)
> And, yes, I came across the issue of not being able to query whether a
> ThreadLocal exists on a Thread when I implemented my prototype. Which
> is why I think introducing an exit hook on ThreadLocal, instead of
> Thread, is probably the better approach (it will only be called if the
> ThreadLocal exists).
>
java.lang.Thread is already tightly connected to blocking I/O operations
(Thread::interrupt for example). In any case, the concern with exposing
exit hooks in the API is that it means running arbitrary code when
exiting, something that would need a lot of consideration before going
there.
-Alan
More information about the core-libs-dev
mailing list