changeset 53649:6df06df9ae2e

8204525: [TESTBUG] runtime/NMT/MallocStressTest.java ran out of java heap Summary: Handle OutOfMemoryError exception to prevent test aborting Reviewed-by: zgu, dholmes
author hseigel
date Mon, 26 Nov 2018 09:46:20 -0500
parents ca9459361300
children c93e62e7fa3c
files test/hotspot/jtreg/runtime/NMT/MallocStressTest.java
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/runtime/NMT/MallocStressTest.java	Mon Nov 26 12:16:23 2018 +0100
+++ b/test/hotspot/jtreg/runtime/NMT/MallocStressTest.java	Mon Nov 26 09:46:20 2018 -0500
@@ -186,13 +186,19 @@
                 if (size == 0) size = 1;
                 long addr = MallocStressTest.whiteBox.NMTMallocWithPseudoStack(size, r);
                 if (addr != 0) {
-                    MallocMemory mem = new MallocMemory(addr, size);
-                    synchronized(MallocStressTest.mallocd_memory) {
-                        MallocStressTest.mallocd_memory.add(mem);
-                        MallocStressTest.mallocd_total += size;
+                    try {
+                        MallocMemory mem = new MallocMemory(addr, size);
+                        synchronized(MallocStressTest.mallocd_memory) {
+                            MallocStressTest.mallocd_memory.add(mem);
+                            MallocStressTest.mallocd_total += size;
+                        }
+                    } catch (OutOfMemoryError e) {
+                        // Don't include this malloc memory because it didn't
+                        // get recorded in mallocd_memory list.
+                        MallocStressTest.whiteBox.NMTFree(addr);
+                        break;
                     }
                 } else {
-                    System.out.println("Out of malloc memory");
                     break;
                 }
             }