Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8196325

GarbageCollectionNotificationInfo has same information for before and after

    Details

    • Subcomponent:
      gc
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "9.0.4"
      Java(TM) SE Runtime Environment (build 9.0.4+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      I am seeing the same problem mentioned in:

       https://bugs.openjdk.java.net/browse/JDK-8027635

      Only on java 9 (that bug was marked as fixed in 7u40). I do not see the problem when using java 8.

      Some additional details at: https://github.com/Netflix/spectator/issues/502

      REGRESSION. Last worked in version 8u172

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Change in amount used for G1 Eden Space after GC.
      ACTUAL -
      No change in amount used for G1 Eden Space after GC.

      REPRODUCIBILITY :N
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // This is from https://bugs.openjdk.java.net/browse/JDK-8027635

      import java.lang.management.GarbageCollectorMXBean;
      import java.lang.management.ManagementFactory;
      import java.lang.management.PlatformManagedObject;
      import java.util.ArrayList;
      import java.util.List;

      import javax.management.Notification;
      import javax.management.NotificationEmitter;
      import javax.management.NotificationListener;
      import javax.management.openmbean.CompositeData;

      import com.sun.management.GarbageCollectionNotificationInfo;

      /**
       *
       */
      public class NotificationTest {

        public static void main(String[] args) {
          for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) {
            addNotificationListener(bean);
          }

          List<String> strings = new ArrayList<String>();
          
          for(int i=0;i<10000;i++) {
            System.out.println(i);
          }
          
          System.gc();
          try {
            Thread.sleep(1000);
          } catch (InterruptedException e) {
          }
        }
        
        public static void addNotificationListener(PlatformManagedObject mbs) {
          if (mbs instanceof NotificationEmitter) {
            NotificationEmitter emitter = (NotificationEmitter)mbs;
            emitter.addNotificationListener(new NotificationListener() {
              @Override
              public void handleNotification(Notification notification, Object handback) {
                String notifType = notification.getType();
                if (notifType.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
                  // retrieve the garbage collection notification information
                  GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from((CompositeData)notification
                          .getUserData());
                  System.out.println(info.getGcInfo().getMemoryUsageBeforeGc());
                  System.out.println(info.getGcInfo().getMemoryUsageAfterGc());
                }
              }
            }, null, null);
          }
        }

      }
      ---------- END SOURCE ----------

        Issue Links

          Activity

          Hide
          fmatte Fairoz Matte added a comment -
          This seems to be exactly duplicate of JDK-8027635 but not closing as duplicate. The initial issue reported against 7u9 but later closed as Not an issue in 7u40 and 8

          Below are the observations with respected to current issue
          ===8u172 ea b03 with default options=== Result = Pass
          Before GC = Eden Space=init = 119537664(116736K) used = 4781544(4669K)
          After GC = Eden Space=init = 119537664(116736K) used = 0(0K)

          ==8u172 ea b03 with G1GC=== Result = Pass
          Before GC = G1 Eden Space=init = 27262976(26624K) used = 2097152(2048K)
          After GC = G1 Eden Space=init = 27262976(26624K) used = 0(0K)

          ===9.0.4 b12 with default options=== Result = Fail
          Before GC = G1 Eden Space=init = 0(0K) used = 584144(570K)
          After GC = G1 Eden Space=init = 0(0K) used = 584144(570K)

          ==10 ea b39 with default options=== Result = Fail
          Before GC = G1 Eden Space=init = 0(0K) used = 576304(562K)
          After GC = G1 Eden Space=init = 0(0K) used = 576304(562K)
          ==


          Show
          fmatte Fairoz Matte added a comment - This seems to be exactly duplicate of JDK-8027635 but not closing as duplicate. The initial issue reported against 7u9 but later closed as Not an issue in 7u40 and 8 Below are the observations with respected to current issue ===8u172 ea b03 with default options=== Result = Pass Before GC = Eden Space=init = 119537664(116736K) used = 4781544(4669K) After GC = Eden Space=init = 119537664(116736K) used = 0(0K) ==8u172 ea b03 with G1GC=== Result = Pass Before GC = G1 Eden Space=init = 27262976(26624K) used = 2097152(2048K) After GC = G1 Eden Space=init = 27262976(26624K) used = 0(0K) ===9.0.4 b12 with default options=== Result = Fail Before GC = G1 Eden Space=init = 0(0K) used = 584144(570K) After GC = G1 Eden Space=init = 0(0K) used = 584144(570K) ==10 ea b39 with default options=== Result = Fail Before GC = G1 Eden Space=init = 0(0K) used = 576304(562K) After GC = G1 Eden Space=init = 0(0K) used = 576304(562K) ==

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: