Java Performance Services
Training, Seminars, Benchmarking, Tuning

Java Performance Tuning Course


Chania Crete
May 22rd-25th 2012

Sydney Australia
Feb 6-9, 2012

Montreal Canada
Feb 27-March 2, 2012

San Francisco CA
March 20-23 2012

Paris France
March 27-March 2, 2012

Request an in-house seminar

Anti-if

I have joined Anti-IF Campaign

Calendar

««May 2012»»
SMTWTFS
   12345
6789101112
13141516171819
20212223242526
2728293031

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!


9. Javin @ Classpath in Java left...
Tuesday, 19 April 2011 3:07 pm :: http://javarevisited.blogspot.com/2011/0

Thanks for putting this information in short and concise format. just to add its important to remember that we need to put "m" or "M" or "G" to denote Mega and Giga in -Xms and -Xmx. Also based upon my experience keeping -Xms and -Xms ration either 1:1 or 1.5:1 works well in terms of minimizing garbage collection.

Thanks Javin <a href="http://javarevisited.blogspot.com/2011/04/garbage-collection-in -java.html">How Garbage collection works in Java </a>