test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorGCTest.java
changeset 51296 d64013e38c11
parent 50579 1596f418ffe4
child 51559 57f1bf06742e
equal deleted inserted replaced
51295:76ffdd60d5bc 51296:d64013e38c11
    41   public static void main(String[] args) {
    41   public static void main(String[] args) {
    42     if (!HeapMonitor.eventStorageIsEmpty()) {
    42     if (!HeapMonitor.eventStorageIsEmpty()) {
    43       throw new RuntimeException("Statistics should be null to begin with.");
    43       throw new RuntimeException("Statistics should be null to begin with.");
    44     }
    44     }
    45 
    45 
       
    46     // Put sampling rate to 100k to ensure samples are collected.
       
    47     HeapMonitor.setSamplingInterval(100 * 1024);
       
    48 
    46     HeapMonitor.enableSamplingEvents();
    49     HeapMonitor.enableSamplingEvents();
    47 
    50 
    48     List<Frame> frameList = HeapMonitor.allocate();
    51     List<Frame> frameList = HeapMonitor.allocate();
    49     frameList.add(new Frame("main", "([Ljava/lang/String;)V", "HeapMonitorGCTest.java", 48));
    52     frameList.add(new Frame("main", "([Ljava/lang/String;)V", "HeapMonitorGCTest.java", 51));
    50     Frame[] frames = frameList.toArray(new Frame[0]);
    53     Frame[] frames = frameList.toArray(new Frame[0]);
    51 
    54 
    52     if (!HeapMonitor.obtainedEvents(frames)) {
    55     if (!HeapMonitor.obtainedEvents(frames)
       
    56         && !HeapMonitor.garbageContains(frames)) {
    53       throw new RuntimeException("No expected events were found.");
    57       throw new RuntimeException("No expected events were found.");
    54     }
    58     }
    55 
    59 
    56     HeapMonitor.forceGarbageCollection();
    60     HeapMonitor.forceGarbageCollection();
    57 
    61