More than 20X slowdown for ManagementFactory.getGarbageCollectorMXBeans()

XMLWordPrintable

      We noticed a large slowdown from ManagementFactory.getGarbageCollectorMXBeans() comparing JDK 8 and JDK 11. The culprit is probably JDK-8065213, which changes it to call stream().flatMap().collect() underneath.

      Using the attached simple loop program, with -XX:-TieredCompilation, JDK 8 takes ~0.2 seconds, JDK 11 takes ~4.5 seconds.

      This method is important for some programs that repeatedly call it to collect statistics about GC. Such a program could cache the returned list of this method. However, according to JavaDocs, the JVM "may add or remove GarbageCollectorMXBean during execution", so caching is not an ideal solution.

            Assignee:
            Unassigned
            Reporter:
            Man Cao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: