IDEA-163334 Memory leak in jdi code - workaround for normal process finish

This commit is contained in:
Egor.Ushakov
2017-02-14 18:45:39 +03:00
parent 1929da8a22
commit d8fc734714
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -383,14 +383,15 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
catch (UnsupportedOperationException e) {
LOG.info(e);
}
if (Patches.JDK_BUG_EVENT_CONTROLLER_LEAK) {
// Memory leak workaround, see IDEA-163334
TargetVM target = ReflectionUtil.getField(myVirtualMachine.getClass(), myVirtualMachine, TargetVM.class, "target");
if (target != null) {
Thread controller = ReflectionUtil.getField(target.getClass(), target, Thread.class, "eventController");
if (controller != null) {
controller.stop();
finally {
if (Patches.JDK_BUG_EVENT_CONTROLLER_LEAK) {
// Memory leak workaround, see IDEA-163334
TargetVM target = ReflectionUtil.getField(myVirtualMachine.getClass(), myVirtualMachine, TargetVM.class, "target");
if (target != null) {
Thread controller = ReflectionUtil.getField(target.getClass(), target, Thread.class, "eventController");
if (controller != null) {
controller.stop();
}
}
}
}