< prev index next >

test/hotspot/jtreg/gc/z/TestHighUsage.java

Print this page




  70             for (int i = 0; i < 300; i++) {
  71                 if (Runtime.getRuntime().freeMemory() > highUsageThreshold) {
  72                     // Allocate
  73                     dummy = new byte[128 * K];
  74                     System.out.println("Free: " + (Runtime.getRuntime().freeMemory() / M) + "M (Allocating)");
  75                 } else {
  76                     // Idle
  77                     System.out.println("Free: " + (Runtime.getRuntime().freeMemory() / M) + "M (Idling)");
  78                 }
  79 
  80                 Thread.sleep(250);
  81             }
  82 
  83             System.out.println("Done");
  84         }
  85     }
  86 
  87     public static void main(String[] args) throws Exception {
  88         ProcessTools.executeTestJvm(new String[]{ "-XX:+UnlockExperimentalVMOptions",
  89                                                   "-XX:+UseZGC",
  90                                                   "-XX:+UnlockDiagnosticVMOptions",
  91                                                   "-XX:-ZProactive",
  92                                                   "-Xms128M",
  93                                                   "-Xmx128M",
  94                                                   "-XX:ParallelGCThreads=1",
  95                                                   "-XX:ConcGCThreads=1",
  96                                                   "-Xlog:gc,gc+start",
  97                                                   Test.class.getName() })
  98                     .shouldNotContain("Allocation Stall")
  99                     .shouldContain("High Usage")
 100                     .shouldHaveExitValue(0);
 101     }
 102 }


  70             for (int i = 0; i < 300; i++) {
  71                 if (Runtime.getRuntime().freeMemory() > highUsageThreshold) {
  72                     // Allocate
  73                     dummy = new byte[128 * K];
  74                     System.out.println("Free: " + (Runtime.getRuntime().freeMemory() / M) + "M (Allocating)");
  75                 } else {
  76                     // Idle
  77                     System.out.println("Free: " + (Runtime.getRuntime().freeMemory() / M) + "M (Idling)");
  78                 }
  79 
  80                 Thread.sleep(250);
  81             }
  82 
  83             System.out.println("Done");
  84         }
  85     }
  86 
  87     public static void main(String[] args) throws Exception {
  88         ProcessTools.executeTestJvm(new String[]{ "-XX:+UnlockExperimentalVMOptions",
  89                                                   "-XX:+UseZGC",

  90                                                   "-XX:-ZProactive",
  91                                                   "-Xms128M",
  92                                                   "-Xmx128M",
  93                                                   "-XX:ParallelGCThreads=1",
  94                                                   "-XX:ConcGCThreads=1",
  95                                                   "-Xlog:gc,gc+start",
  96                                                   Test.class.getName() })
  97                     .shouldNotContain("Allocation Stall")
  98                     .shouldContain("High Usage")
  99                     .shouldHaveExitValue(0);
 100     }
 101 }
< prev index next >