test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java
changeset 51136 6d6611346837
parent 50579 1596f418ffe4
child 51138 914f305ba6fa
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java	Tue Jul 17 11:20:16 2018 -0700
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java	Tue Jul 17 15:09:27 2018 -0700
@@ -46,8 +46,6 @@
   public static void main(String[] args) {
     int sizes[] = {1000, 10000, 100000};
 
-    HeapMonitor.enableSamplingEvents();
-
     for (int currentSize : sizes) {
       System.out.println("Testing size " + currentSize);
 
@@ -56,12 +54,16 @@
         throw new RuntimeException("Should not have any events stored yet.");
       }
 
+      HeapMonitor.enableSamplingEvents();
+
       // 111 is as good a number as any.
       final int samplingMultiplier = 111;
       HeapMonitor.setSamplingRate(samplingMultiplier * currentSize);
 
       allocate(currentSize);
 
+      HeapMonitor.disableSamplingEvents();
+
       // For simplifications, we ignore the array memory usage for array internals (with the array
       // sizes requested, it should be a negligible oversight).
       //