< prev index next >

test/hotspot/jtreg/gc/shenandoah/mxbeans/TestChurnNotifications.java

Print this page
*** 1,7 ***
--- 1,8 ---
  /*
   * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 102,10 ***
--- 103,22 ---
   *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
   *      -Dprecise=false
   *      TestChurnNotifications
   */
  
+ /*
+  * @test id=generational
+  * @summary Check that MX notifications are reported for all cycles
+  * @library /test/lib /
+  * @requires vm.gc.Shenandoah
+  *
+  * @run main/othervm -Xmx128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
+  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
+  *      -Dprecise=false -Dmem.pool=Young
+  *      TestChurnNotifications
+  */
+ 
  import java.util.*;
  import java.util.concurrent.atomic.*;
  import javax.management.*;
  import java.lang.management.*;
  import javax.management.openmbean.*;

*** 126,10 ***
--- 139,12 ---
  
      static final long M = 1024 * 1024;
  
      static volatile Object sink;
  
+     private static final String POOL_NAME = "Young".equals(System.getProperty("mem.pool")) ? "Shenandoah Young Gen" : "Shenandoah";
+ 
      public static void main(String[] args) throws Exception {
          final long startTimeNanos = System.nanoTime();
  
          final AtomicLong churnBytes = new AtomicLong();
  

*** 139,12 ***
                  if (n.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
                      GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from((CompositeData) n.getUserData());
                      Map<String, MemoryUsage> mapBefore = info.getGcInfo().getMemoryUsageBeforeGc();
                      Map<String, MemoryUsage> mapAfter = info.getGcInfo().getMemoryUsageAfterGc();
  
!                     MemoryUsage before = mapBefore.get("Shenandoah");
!                     MemoryUsage after = mapAfter.get("Shenandoah");
  
                      if ((before != null) && (after != null)) {
                          long diff = before.getUsed() - after.getUsed();
                          if (diff > 0) {
                              churnBytes.addAndGet(diff);
--- 154,12 ---
                  if (n.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
                      GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from((CompositeData) n.getUserData());
                      Map<String, MemoryUsage> mapBefore = info.getGcInfo().getMemoryUsageBeforeGc();
                      Map<String, MemoryUsage> mapAfter = info.getGcInfo().getMemoryUsageAfterGc();
  
!                     MemoryUsage before = mapBefore.get(POOL_NAME);
!                     MemoryUsage after = mapAfter.get(POOL_NAME);
  
                      if ((before != null) && (after != null)) {
                          long diff = before.getUsed() - after.getUsed();
                          if (diff > 0) {
                              churnBytes.addAndGet(diff);
< prev index next >