Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Johnson2018-11-26 07:35:02 -0500
committerAndrew Johnson2018-11-26 07:35:02 -0500
commitf6aa6674ff450d07c70113a1f02b87d2e76fc663 (patch)
tree8b540228c36b79a26b46ca21b40e558ce63be4e3
parent7de2189059ac6668422c662bb1c22566c532a942 (diff)
downloadorg.eclipse.mat-f6aa6674ff450d07c70113a1f02b87d2e76fc663.tar.gz
org.eclipse.mat-f6aa6674ff450d07c70113a1f02b87d2e76fc663.tar.xz
org.eclipse.mat-f6aa6674ff450d07c70113a1f02b87d2e76fc663.zip
[541539] Simple batch mode comparison of two snapshots
Snapshots from a factory should be disposed via the factory. Change-Id: I1ff9f4b80a44b7804b886d9d15ba0435fae73333
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/DeltaHistogram.java3
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotFactory.java6
-rw-r--r--plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java4
-rw-r--r--plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java4
4 files changed, 12 insertions, 5 deletions
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/DeltaHistogram.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/DeltaHistogram.java
index 224bf32a..87223e5b 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/DeltaHistogram.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/DeltaHistogram.java
@@ -19,6 +19,7 @@ import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.query.annotations.Argument.Advice;
import org.eclipse.mat.snapshot.Histogram;
import org.eclipse.mat.snapshot.ISnapshot;
+import org.eclipse.mat.snapshot.SnapshotFactory;
import org.eclipse.mat.util.IProgressListener;
import org.eclipse.mat.util.SimpleMonitor;
@@ -39,6 +40,8 @@ public class DeltaHistogram extends HistogramQuery
Histogram h2 = (Histogram) super.execute(sm.nextMonitor());
sm.nextMonitor();
Histogram h3 = h2.diffWithBaseline(h1);
+ // Currently it seems a SECONDARY_SNAPSHOT is not disposed by the caller.
+ SnapshotFactory.dispose(snapshot2);
listener.done();
return h3;
}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotFactory.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotFactory.java
index 12d5d873..1620f51a 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotFactory.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and IBM Corporation.
+ * Copyright (c) 2008, 2018 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -55,6 +55,8 @@ public final class SnapshotFactory
/**
* Free resources when the snapshot is no longer needed.
+ * Use instead of {@link ISnapshot#dispose()} if the snapshot is obtained from {@link #openSnapshot(File, Map, IProgressListener)}
+ * as openSnapshot() may obtain a copy from a cache.
* @param snapshot
*/
void dispose(ISnapshot snapshot);
@@ -153,6 +155,8 @@ public final class SnapshotFactory
* main memory, file and socket handles...) when the last user has disposed
* it through the snapshot factory. After calling this method the snapshot
* can't be used anymore.
+ * Use instead of {@link ISnapshot#dispose()} if the snapshot is obtained from {@link #openSnapshot(File, Map, IProgressListener)}
+ * as openSnapshot() may obtain a copy from a cache.
*
* @param snapshot
* snapshot which should be disposed
diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java
index 17ad4f7e..eb9ff272 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015,2017 IBM Corporation.
+ * Copyright (c) 2015, 2018 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -154,7 +154,7 @@ public class AcquireDumpTest
}
finally
{
- answer.dispose();
+ SnapshotFactory.dispose(answer);
}
}
finally
diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java
index 5be89653..076b8500 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java
@@ -897,7 +897,7 @@ public class QueriesTest
assertNotNull(t);
ISnapshot newSnapshot = SnapshotFactory.openSnapshot(fn, Collections.<String,String>emptyMap(), new VoidProgressListener());
assertNotNull(newSnapshot);
- newSnapshot.dispose();
+ SnapshotFactory.dispose(newSnapshot);
}
finally
{
@@ -954,7 +954,7 @@ public class QueriesTest
ISnapshot newSnapshot = SnapshotFactory.openSnapshot(fn, Collections.<String, String> emptyMap(),
new VoidProgressListener());
assertNotNull(newSnapshot);
- newSnapshot.dispose();
+ SnapshotFactory.dispose(newSnapshot);
}
finally
{

Back to the top