Java Performance Services
Training, Seminars, Benchmarking, Tuning

Java Performance Tuning Course


Chania Crete, May 17-20, 2010


Sun Extreme Learning EXL-2025

Houston, December 1-4,2009
New York, December 8-11, 2009
Washington DC, January 5-8, 2010



San Francisco, January 11-14

Anti-if

I have joined Anti-IF Campaign

Calendar

««Nov 2009»»
SMTWTFS
1234
5
67
891011121314
15161718192021
22232425262728
2930

Performance Anti-Patterns

My Top Tags

                                       

Mailing List

My RSS Feeds








Neat Java Heap Dump Trick

posted Saturday, 28 March 2009

Last week I was in Tallinn teaching my performance tuning course and during the last exercise, one of the attendees wanted to know what was in a cache that they'd instrumented the application to use. Lacking any means to dump the contents of the cache, I suggested that he use jmap to create a heap dump and then use NetBeans HeapWalker to inspect the contents.

Using the filtering capabilities of NetBeans heap tool, we quickly found the map that contained all of the cached objects. While it did take a wee bit of time to walk through the contents of the collection, he did manage to find an answer to his question. While it might have been easier to alter the caching code to get an answer, this could be useful if you can't alter code and you've no other visibility into some internal data structure, this could be an answer.

tags:          




1. Marre left...
Saturday, 28 March 2009 3:29 pm

You should also try Eclipse Memory Analyzer at http://www.eclipse.org/mat/. It is a bit slower at startup, but after it has analyzed the entire heap it is much faster to use.


2. Kirk Pepperdine left...
Sunday, 29 March 2009 5:31 am

MAT is much better than what has been available but relies on the old IBM idea of dominators. NetBeans uses Generations, a much more powerful measurement with 0 false positives. This is not be confused with Generations in YourKit which while useful, is a stripped down version of NBP definition of Generations. Other than that, I give YourKit my full endorsement.

If you are glued to Eclipse, you need to look at Holly Cummings contribution to IBMs Health Center (see Parleys 2009 performance tool University session). That is a very good tool.


3. William Louth left...
Monday, 30 March 2009 5:22 pm :: http://williamlouth.wordpress.com

A whole heap dump just so you can inspect a map !!!!!

I can do this in one line of code or even better a few lines of xml.

State Observation: The Good (JXI), Bad (JMX), Ugly (JMX) http://williamlouth.wordpress.com/2008/07/16/the-good-jxinsight-bad-jmx-ugl y-jmx/


4. Kirk Pepperdine left...
Tuesday, 31 March 2009 1:57 am

William, not if the VM is currently running and you don't want to restart it... ;-)


5. William Louth left...
Tuesday, 31 March 2009 7:04 am :: http://www.jinspired.com

Kirk customers would typically have already identified the main state and execution components and points prior to going into production. Anything ending with *Manager, *Cache, *Contex, *Session,..... Then it is just a matter of request a diagnostic snapshot of those objects (types) you wish to observe. If you do not know this prior to going into production then you are not managing your applications.

William


6. Kirk Pepperdine left...
Tuesday, 31 March 2009 7:42 am

Of course this is not a good substitute for instrumenting memory critical sections of your code while developing the application. IME, typical applications are not properly instrumented to answer memory related questions. Heck, they barely get time budgeting right in many cases! It's a hack that says, if you've got no other way.. there is a way. Anyone having to use this hack more than once will quickly switch to some sort of instrumentation 'cos this works but it's a wee bit painful.

BTW, if you'd like to properly advertise JXInsight on my site, please let me know, I'll be happy to quote you a great rate. :-)


7. William Louth left...
Tuesday, 31 March 2009 12:57 pm :: http://williamlouth.wordpress.com

Advertising rate? Only if you do the endorsement and not me, ;-).

But you are right. Sorry. I will stay away (for a while).


8. Kirk Pepperdine left...
Tuesday, 31 March 2009 6:55 pm

NOOOOO William.. don't stay away, you are fun! Come on.. we need to take things more lightly.. it's only technology and dude, you're a fun guy when you lighten up!