Skip to content

Commit a32037a

Browse files
committed
hard reference JmxModel so we are sure that it is not garbage collected
1 parent 7de7066 commit a32037a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

visualvm/jmx/src/org/graalvm/visualvm/jmx/impl/JmxApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public final class JmxApplication extends Application {
5656
// since getting JVM for the first time can take a long time
5757
// hard reference jvm from application so we are sure that it is not garbage collected
5858
public Jvm jvm;
59+
JmxModel jmxModel;
5960

6061
// Note: storage may be null, in this case the JmxApplication isn't persistent
6162
// and creates a temporary storage just like any other regular Application
@@ -100,6 +101,7 @@ public void setStateImpl(int newState) {
100101
if (newState != Stateful.STATE_AVAILABLE) {
101102
pid = UNKNOWN_PID;
102103
jvm = null;
104+
jmxModel = null;
103105
}
104106
setState(newState);
105107
}

visualvm/jmx/src/org/graalvm/visualvm/jmx/impl/JmxApplicationProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ public void run() {
385385
} else {
386386
app.setStateImpl(Stateful.STATE_AVAILABLE);
387387

388-
model = JmxModelFactory.getJmxModelFor(app);
388+
app.jmxModel = JmxModelFactory.getJmxModelFor(app);
389389
app.jvm = JvmFactory.getJVMFor(app);
390390

391-
model.addPropertyChangeListener(new PropertyChangeListener() {
391+
app.jmxModel.addPropertyChangeListener(new PropertyChangeListener() {
392392
public void propertyChange(PropertyChangeEvent evt) {
393393
if (evt.getNewValue() == ConnectionState.CONNECTED) {
394394
app.setStateImpl(Stateful.STATE_AVAILABLE);

0 commit comments

Comments
 (0)