Allocated All Pools and HotSpot Anonymous Classes

Questions about YourKit Java Profiler
projectvalhalla
Posts: 12
Joined: Sun Jul 27, 2014 8:28 pm

Re: Allocated All Pools and HotSpot Anonymous Classes

Post by projectvalhalla »

The problem is in the Java 7 VM, but is triggered only when agent performs bytecode instrumentation of loaded classes.
But wouldn't that mean that the instrumentations performed by the agent generate invocations into YourKit runtime methods which keep on allocating more and more memory?

Or in other words, YourKit only gets to know that there is a new class generated, if some code injected by YourKit within that class is executed, like in <clinit>?

So, the issue is, like you said, really with the JVM TI profiling interface not reporting class loading and unloading events for those dynamically generated classes.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Allocated All Pools and HotSpot Anonymous Classes

Post by Anton Katilin »

We're still investigating, but we tend to blame JVM.

Code injection by itself does not allocate any memory structures on the agent side that would require to be freed on class unload. Furthermore, bytecode transformation (code injection or removal) can be performed multiple times for the same class, when profiling modes are turned on/off in runtime. In other words, bytecode instrumentation does not depend on class unload event availability in no way, and does not require any cleanup. Technically, bytecode instrumentation and class load/unload events are different beasts in JVMTI.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Allocated All Pools and HotSpot Anonymous Classes

Post by Anton Katilin »

We confirm it's a bug in Java 7. We've proved this fact with a trivial isolated JVMTI agent. The agent clearly does not leak memory by itself, but the JVM process memory grows as the result of specific JVMTI calls.

We'll file a bug report to Oracle, although I personally don't believe they will fix it.

To address this issue right now, either use Java 8 or specify the agent startup options "disablealloc,disabletracing" for Java 7.
projectvalhalla
Posts: 12
Joined: Sun Jul 27, 2014 8:28 pm

Re: Allocated All Pools and HotSpot Anonymous Classes

Post by projectvalhalla »

Okay. Maybe Oracle can backport the fix already in Java 8 back into 7.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Allocated All Pools and HotSpot Anonymous Classes

Post by Anton Katilin »

We've filed the report. They'll review it. I'll notify when/if we receive an update.

Review ID: JI-9013837 - Memory leak in ClassFileLoadHook with Unsafe.defineAnonymousClass()
projectvalhalla
Posts: 12
Joined: Sun Jul 27, 2014 8:28 pm

Re: Allocated All Pools and HotSpot Anonymous Classes

Post by projectvalhalla »

Hello vutaikt,

you are welcome! :-)

Do you mean with "working done" that you found a bug and fixed it so that defining many short-lived classes now does not lead to a memory leak anymore?

Can you say when and if the fix is being included in a next Java 7 release?

Oh, and by the way, can you or Anton please post a full URL to the bug ticket, since I cannot find any ticket via http://bugs.java.com/ either via "JI-9013837" or "9013837".

Thanks for fixing!
projectvalhalla
Posts: 12
Joined: Sun Jul 27, 2014 8:28 pm

Re: Allocated All Pools and HotSpot Anonymous Classes

Post by projectvalhalla »

Oh, and by the way, can you or Anton please post a full UR...
Oh, never mind. Google happened to find it on https://bugs.openjdk.java.net/browse/JDK-8054109 :-)
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Allocated All Pools and HotSpot Anonymous Classes

Post by Anton Katilin »

Thank you for finding this bug.
By the way, we have not yet received any notification that it was opened.
Anyway, it now shows "7u80" in the "Fix Version/s:" field.
Post Reply