fixed memory leak from ThreadsDebuggerTree$1

This commit is contained in:
Egor.Ushakov
2017-05-18 18:37:37 +03:00
parent 8bbdde7d71
commit 344a1ec47e
4 changed files with 15 additions and 26 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 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.
@@ -167,8 +167,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
return myCurrentTooltip;
}
myCurrentTooltipNode = node;
final String toolTipText = getTipText(node);
if (toolTipText == null) {
return null;
@@ -229,6 +227,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
toolTip.setPreferredSize(tipRectangle.getSize());
myCurrentTooltip = toolTip;
myCurrentTooltipNode = node;
return myCurrentTooltip;
}
@@ -90,6 +90,14 @@ public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements
protected abstract DebuggerTree createTreeView();
@Override
protected void changeEvent(DebuggerContextImpl newContext, DebuggerSession.Event event) {
super.changeEvent(newContext, event);
if (event == DebuggerSession.Event.DISPOSE) {
getTree().getNodeFactory().dispose();
}
}
@Override
protected void rebuild(DebuggerSession.Event event) {
myRebuildAlarm.cancelAndRequest();
@@ -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.
@@ -31,7 +31,6 @@ import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.jdi.LocalVariableProxyImpl;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
@@ -71,7 +70,9 @@ import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvider {
@@ -328,21 +329,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
protected abstract void build(DebuggerContextImpl context);
protected final void buildWhenPaused(DebuggerContextImpl context, RefreshDebuggerTreeCommand command) {
DebuggerSession session = context.getDebuggerSession();
if (ApplicationManager.getApplication().isUnitTestMode() || (session != null && session.getState() == DebuggerSession.State.PAUSED)) {
showMessage(MessageDescriptor.EVALUATING);
context.getDebugProcess().getManagerThread().schedule(command);
}
else {
showMessage(session != null? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
if (session == null || session.isStopped()) {
getNodeFactory().clearHistory(); // save memory by clearing references on JDI objects
}
}
}
public void rebuild(final DebuggerContextImpl context) {
ApplicationManager.getApplication().assertIsDispatchThread();
final DebugProcessImpl process = context.getDebugProcess();
@@ -139,12 +139,8 @@ public class NodeManagerImpl extends NodeDescriptorFactoryImpl implements NodeMa
}
public void dispose() {
clearHistory();
super.dispose();
}
public void clearHistory() {
myHistories.clear();
super.dispose();
}
private DebuggerTree getTree() {