Mercurial > hg > graal-jvmci-8
changeset 22453:d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 21 Aug 2015 16:35:29 +0200 |
parents | b6fd47c5dc0b |
children | 76af33d4d504 |
files | jvmci/jdk.internal.jvmci.hotspot.jfr/src/jdk/internal/jvmci/hotspot/jfr/events/JFREventProvider.java |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.hotspot.jfr/src/jdk/internal/jvmci/hotspot/jfr/events/JFREventProvider.java Fri Aug 21 13:18:40 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot.jfr/src/jdk/internal/jvmci/hotspot/jfr/events/JFREventProvider.java Fri Aug 21 16:35:29 2015 +0200 @@ -40,9 +40,15 @@ private final boolean enabled; + /** + * Need to store the producer in a field so that it doesn't disappear. + */ + @SuppressWarnings({"deprecation", "unused"}) private final Producer producer; + @SuppressWarnings("deprecation") public JFREventProvider() { enabled = HotSpotJVMCIRuntime.runtime().getConfig().flightRecorder; + Producer p = null; if (enabled) { try { /* @@ -51,19 +57,20 @@ * doesn't show JVMCI events in the "Code" tab. There are plans to revise the JFR * code for JDK 9. */ - Producer producer = new Producer("HotSpot JVM", "Oracle Hotspot JVM", "http://www.oracle.com/hotspot/jvm/"); - producer.register(); + p = new Producer("HotSpot JVM", "Oracle Hotspot JVM", "http://www.oracle.com/hotspot/jvm/"); + p.register(); // Register event classes with Producer. for (Class<?> c : JFREventProvider.class.getDeclaredClasses()) { if (c.isAnnotationPresent(EventDefinition.class)) { assert com.oracle.jrockit.jfr.InstantEvent.class.isAssignableFrom(c) : c; - registerEvent(producer, c); + registerEvent(p, c); } } } catch (URISyntaxException e) { throw new InternalError(e); } } + this.producer = p; } /**