From 216b0b39f43348e15c3410d560a14ea9db30ebf2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 19 Jan 2021 15:32:52 +0000 Subject: [PATCH] 570485: CI Build failures due to OutOfMemoryError or SIGKILL Dispose of snapshots from collection tests when not needed anymore. Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570485 Change-Id: I76f271352244efb9a44104e65d99eaf508c2d75e --- .../org/eclipse/mat/tests/TestSnapshots.java | 22 +++++++++++++++++++ .../ExtractCollectionEntriesTest3.java | 9 ++++++++ 2 files changed, 31 insertions(+) diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/TestSnapshots.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/TestSnapshots.java index 8d962e045..b641dbe97 100644 --- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/TestSnapshots.java +++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/TestSnapshots.java @@ -109,6 +109,28 @@ public static ISnapshot getSnapshot(String name, boolean pristine) return getSnapshot(name, new HashMap(), pristine); } + /** + * This snapshot can be disposed as it won't be used again. + * The dump file itself is not deleted, but will be tidied up + * at the end. + * @param name + * @return true if successfully disposed. + */ + public static boolean freeSnapshot(String name) + { + ISnapshot answer = snapshots.get(name); + if (answer != null) + { + answer.dispose(); + snapshots.remove(name); + return true; + } + else + { + return false; + } + } + /** * Get a snapshot from a dump * diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ExtractCollectionEntriesTest3.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ExtractCollectionEntriesTest3.java index f4dadfb34..c8932f2b3 100644 --- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ExtractCollectionEntriesTest3.java +++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ExtractCollectionEntriesTest3.java @@ -210,6 +210,8 @@ public static Collection data3() throws SnapshotException, IOException if (objects != null) parms.add(objects); } + Object[] objects = new Object[] { dmppath, dmpname, 7, null}; + parms.add(objects); // To ensure it isn't garbage collected early System.out.println(cdp); } @@ -251,6 +253,13 @@ public void testCollections() throws SnapshotException assumeThat(type, equalTo(6)); testCollections6(TestSnapshots.getSnapshot(snapfile,false), classname); break; + case 7: + assumeThat(type, equalTo(7)); + if (TestSnapshots.freeSnapshot(snapfile)) + { + System.out.println("Unable to dispose of snapshot " + snapfile); + } + break; } }