users@glassfish.java.net

Re: How to get a memory snapshot

From: <glassfish_at_javadesktop.org>
Date: Tue, 11 Nov 2008 11:27:46 PST

VisualVM uses various technologies to access the monitored applications: jvmstat, JMX, Attach API etc. Based on the monitored application setup some of the technologies may not be available - for example Attach API is only available on JDK 6, jvmstat can only be used to access applications launched by the same user.

The reason why you don't see Profiler tab and some other features are disabled for the Glassfish service is that it doesn't run in context of the user. You can check it by the jps command - if it doesn't list the Glassfish process, VisualVM doesn't know about it. If you connect to the server using the JMX, only the metrics/operations published by MBeans are available, which doesn't cover profiling (which requires Attach API).

Afaik the only way to profile Glassfish using VisualVM is to start the server manually as a Java process (asadmin start-domain...). But note that neither the NetBeans profiler nor VisualVM will let you compare two heap dumps. Currently only comparing two (profiler) memory snapshots taken with the same settings is supported.

Anyway, based on what information is available in the heap dump only number of instances and their sizes could be compared, which is exactly what you get (and even more) when you compare two memory snapshots taken by the profiler. Another possibility to hunt for the leak is simply profile memory and reset the results before invoking the action/operation which could potentially leak - this way you will only see the newly created objects and - if enabled - their allocation stack traces.

Hope this helps,
Jiri
[Message sent by forum member 'jsedlacek' (jsedlacek)]

http://forums.java.net/jive/thread.jspa?messageID=316086