test/jdk/jdk/jfr/event/gc/stacktrace/AllocationStackTrace.java
changeset 59053 ba6c248cae19
parent 50113 caf115bb98ad
equal deleted inserted replaced
59051:f0312c7d5b37 59053:ba6c248cae19
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   208 
   208 
   209         testAllocEvent(bean, memory, expectedStack);
   209         testAllocEvent(bean, memory, expectedStack);
   210     }
   210     }
   211 
   211 
   212     /**
   212     /**
   213      * Tests event stacktrace for young GC if -XX:+UseConcMarkSweepGC is used
       
   214      */
       
   215     public static void testParNewAllocEvent() throws Exception {
       
   216         GarbageCollectorMXBean bean = garbageCollectorMXBean("ParNew");
       
   217         MemoryAllocator memory = new EdenMemoryAllocator();
       
   218 
       
   219         String[] expectedStack = new String[]{
       
   220             "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent",
       
   221             "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testParNewAllocEvent"
       
   222         };
       
   223 
       
   224         testAllocEvent(bean, memory, expectedStack);
       
   225     }
       
   226 
       
   227     /**
       
   228      * Tests event stacktrace for old GC if -XX:+UseConcMarkSweepGC is used
       
   229      */
       
   230     public static void testConcMarkSweepAllocEvent() throws Exception {
       
   231         GarbageCollectorMXBean bean = garbageCollectorMXBean("ConcurrentMarkSweep");
       
   232         MemoryAllocator memory = new OldGenMemoryAllocator();
       
   233 
       
   234         String[] expectedStack = new String[]{
       
   235             "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent",
       
   236             "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testConcMarkSweepAllocEvent"
       
   237         };
       
   238 
       
   239         testAllocEvent(bean, memory, expectedStack);
       
   240     }
       
   241 
       
   242     /**
       
   243      * Tests event stacktrace during metaspace GC threshold if
       
   244      * -XX:+UseConcMarkSweepGC is used
       
   245      */
       
   246     public static void testMetaspaceConcMarkSweepGCAllocEvent() throws Exception {
       
   247         GarbageCollectorMXBean bean = garbageCollectorMXBean("ConcurrentMarkSweep");
       
   248         MemoryAllocator memory = new MetaspaceMemoryAllocator();
       
   249 
       
   250         String[] expectedStack = new String[]{
       
   251             "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent",
       
   252             "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testMetaspaceConcMarkSweepGCAllocEvent"
       
   253         };
       
   254 
       
   255         testAllocEvent(bean, memory, expectedStack);
       
   256     }
       
   257 
       
   258     /**
       
   259      * Tests event stacktrace for young GC if -XX:+UseParallelGC is used
   213      * Tests event stacktrace for young GC if -XX:+UseParallelGC is used
   260      */
   214      */
   261     public static void testParallelScavengeAllocEvent() throws Exception {
   215     public static void testParallelScavengeAllocEvent() throws Exception {
   262         GarbageCollectorMXBean bean = garbageCollectorMXBean("PS Scavenge");
   216         GarbageCollectorMXBean bean = garbageCollectorMXBean("PS Scavenge");
   263         MemoryAllocator memory = new EdenMemoryAllocator();
   217         MemoryAllocator memory = new EdenMemoryAllocator();