On May 3, 2011, at 6:01 PM, Jan Goyvaerts wrote:

> Hello Good Java People,
> 
> I have a question about the way a JVM is supposed to collect local variables. 
> I'm a bit embarrassed as it looks to me it's a newbie question, but I'm 
> puzzled by what's on my screen. :-)
> 
> I'm currently investigating a memory leak in a typical 
> (MySQL/Tomcat/Hibernate/Spring) server application. VisualVM indicates an 
> increasing number of instances of let's say @Entity class Foo. While the 
> batch process is supposed to process Foo one instance at a time.
> 
> The process is a look in which a local variable of Foo is created, processed 
> and then evicted from the Hibernate session for good measure. VisualVM 
> indicates all the instances of Foo being held in memory by a GC Root called 
> "JNI Global". (Except one: the one currently being processed.) Which usually 
> indicates native code hasn't released yet the object. I have no native code 
> in this application. I've tried all sorts of strategies and version of the 
> JVM, but I'm still seeing the same behavior. Each new cycle of the loop 
> creates a new instance of Foo without releasing the previous one.

JDBC driver will make use of native code.

and different behavior on Windows vs Linus is a bug.


Try this,

Attach the memory profiler from VisualVM. Make sure to have the "profile object 
allocations and GC" radio button checked. You also want to also check the 
collect allocation stack traces.
Run the app and sort the profiling results by generational count. Look for 
domain classes at the top of the list. They should have a large gen count if 
they are leaking. Take a heap dump and look at the reference chains for the 
objects with large generational counts. If you take a snapshot, you can look at 
allocation stack traces for those objects also. That should tell you whats 
going on.

That said, I'd bet on my original statement that you're looking at a bug in the 
VM.

Regards,
Kirk

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to