Can we view objects in the JVM memory?

Sebastien Lorber picture Sebastien Lorber · May 11, 2010 · Viewed 9k times · Source

At work we found that on some instances (particulary the slow ones) we have a different behaviour, acquired at the reboot.

We guess a cache is not initialized correctly, or maybe a concurrency problem... Anyway it's not reproductible in any other env than production.

We actually don't have loggers to activate... it's an old component...

Thus i'd like to know if there are tools that can help us to see the different objets present in the JVM memory in order to check the content of the cache...

Thank you!

Edit:

I don't have access to the production servers directly, our app server is weblogic 10, i don't have a pointer to the object but i know the cache object type...

Edit2:

Our servers are running on jre 1.5, is it possible to use jmap? Can't find it in a jdk5 :( Also, remote debugging could be nice but we can't for security reasons...

Edit3:

Actually jhat + VisualVM is ok for me, i found my object in dump but i'm not able to read the hashmap (object containing about 60000 items) properly... Is there a tool to read a concurrenthashmap in a friendly way? i need to find the value of a key (or its existence in the map) without browsing manually the 60k records. Actually i read on eclipse MAT forum that it's also not possible with it...

Edit4: After some experiences i really like tools like VisualVM. Also used YourKit. There are some useful features like OQL to find the right instances you need to look at...

Answer

mezmo picture mezmo · May 11, 2010

This is basically to expand on what Will said. I've had great success by having our admins do a heapdump of our production systems, though with the caveat that the particular server you are dumping will be non-responsive until the dump completes. Then getting that file and using the Eclipse MAT plugin to look at it. If you don't like Eclipse, Netbeans and the plain VisualVM plugin can be used as well. This can create some big files though, you may need to run on a 64 bit system.