diff options
Diffstat (limited to 'test/114-ParallelGC/src/Main.java')
-rw-r--r-- | test/114-ParallelGC/src/Main.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/test/114-ParallelGC/src/Main.java b/test/114-ParallelGC/src/Main.java index 46029cf..159dd5c 100644 --- a/test/114-ParallelGC/src/Main.java +++ b/test/114-ParallelGC/src/Main.java @@ -53,20 +53,21 @@ public class Main implements Runnable { } // Allocate objects to definitely run GC before quitting. - ArrayList<Object> l = new ArrayList<Object>(); - try { - for (int i = 0; i < 100000; i++) { - l.add(new ArrayList<Object>(i)); - } - } catch (OutOfMemoryError oom) { - } - // Make the (outer) ArrayList unreachable. Note it may still - // be reachable under an interpreter or a compiler without a - // liveness analysis. - l = null; + allocateObjectsToRunGc(); + new ArrayList<Object>(50); } + private static void allocateObjectsToRunGc() { + ArrayList<Object> l = new ArrayList<Object>(); + try { + for (int i = 0; i < 100000; i++) { + l.add(new ArrayList<Object>(i)); + } + } catch (OutOfMemoryError oom) { + } + } + private Main(CyclicBarrier startBarrier) { this.startBarrier = startBarrier; } |