< prev index next >

test/gc/g1/TestEagerReclaimHumongousRegions.java

Print this page




  65             // A large object that will be reclaimed eagerly.
  66             large = new int[6*M];
  67             genGarbage();
  68             // Make sure that the compiler cannot completely remove
  69             // the allocation of the large object until here.
  70             System.out.println(large);
  71         }
  72 
  73         // Keep the reference to the first object alive.
  74         System.out.println(ref_from_stack);
  75     }
  76 }
  77 
  78 public class TestEagerReclaimHumongousRegions {
  79     public static void main(String[] args) throws Exception {
  80         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  81             "-XX:+UseG1GC",
  82             "-Xms128M",
  83             "-Xmx128M",
  84             "-Xmn16M",
  85             "-XX:+PrintGC",
  86             ReclaimRegionFast.class.getName());
  87 
  88         Pattern p = Pattern.compile("Full GC");
  89 
  90         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  91 
  92         int found = 0;
  93         Matcher m = p.matcher(output.getStdout());
  94         while (m.find()) { found++; }
  95         System.out.println("Issued " + found + " Full GCs");
  96         Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");
  97 
  98         output.shouldHaveExitValue(0);
  99     }
 100 }


  65             // A large object that will be reclaimed eagerly.
  66             large = new int[6*M];
  67             genGarbage();
  68             // Make sure that the compiler cannot completely remove
  69             // the allocation of the large object until here.
  70             System.out.println(large);
  71         }
  72 
  73         // Keep the reference to the first object alive.
  74         System.out.println(ref_from_stack);
  75     }
  76 }
  77 
  78 public class TestEagerReclaimHumongousRegions {
  79     public static void main(String[] args) throws Exception {
  80         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  81             "-XX:+UseG1GC",
  82             "-Xms128M",
  83             "-Xmx128M",
  84             "-Xmn16M",
  85             "-Xlog:gc",
  86             ReclaimRegionFast.class.getName());
  87 
  88         Pattern p = Pattern.compile("Full GC");
  89 
  90         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  91 
  92         int found = 0;
  93         Matcher m = p.matcher(output.getStdout());
  94         while (m.find()) { found++; }
  95         System.out.println("Issued " + found + " Full GCs");
  96         Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");
  97 
  98         output.shouldHaveExitValue(0);
  99     }
 100 }
< prev index next >