8202788: Explicitly reclaim cached thread-local direct buffers at thread exit

Add internal TerminatingThreadLocal and use it to free cached thread-local direct buffers and nio-fs native buffers

Reviewed-by: tonyp, alanb
This commit is contained in:
Peter Levart 2018-06-22 17:56:55 +02:00
parent 578576f523
commit 6ec2cfcc49
8 changed files with 398 additions and 47 deletions

View file

@ -36,6 +36,8 @@ import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.LockSupport;
import jdk.internal.misc.TerminatingThreadLocal;
import sun.nio.ch.Interruptible;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
@ -838,6 +840,9 @@ class Thread implements Runnable {
* a chance to clean up before it actually exits.
*/
private void exit() {
if (TerminatingThreadLocal.REGISTRY.isPresent()) {
TerminatingThreadLocal.threadTerminated();
}
if (group != null) {
group.threadTerminated(this);
group = null;