Social and professional networking

View Ian Clarke's profile on LinkedIn
Shameless plug

Does your company's revenue depend on being able to predict the future based on past data?  SenseArray may be able to help.

RSS
Links
« The GOP's war on healthcare ignores facts, and history | Main | I've found a new URL shortener »
Thursday
03Dec2009

A great tip for diagnosing Java memory issues

My good friend (and creator of Apache Wicket) Jonathan Locke just gave me a great tip.  I was aware of the jmap utility, but didn't know it could do this:

Just type:

jmap -histo:live <pid>

Where <pid> is the process id of a Java process, and it will dump out all objects, starting with whichever is taking up the most memory.

The handy thing is that the Java process doesn't need to have been started with any kind of special command line options, it will work with any running Java process.

I wish I knew this a few weeks ago while debugging a memory leak on a remote server...

Reader Comments (5)

If you have a fairly current JDK (and not just a JRE) in the relevant environment, you can also use VisualVM. It's essentially is nice GUI that runs on top of jmap, jstat, jinfo, and several other command line JVM tools. You can ask for a heap dump from any JVM visible to your current user and then browse it graphically. Considering that it's free, it's amazingly powerful.

December 3, 2009 | Unregistered CommenterMatt Passell

Matt, thanks for the pointer. My main gripe with visualvm is that its very difficult to get it to connect to an application running on a remote server via an ssh tunnel (something I need to do very frequently).

December 14, 2009 | Unregistered CommenterIan Clarke

Enterprise applications written in the Java language involve complex object relationships and utilize large numbers of objects. Although, the Java language automatically manages memory associated with object life cycles, understanding the application usage patterns for objects is important.

January 15, 2010 | Unregistered CommenterBrian Trane

Hey Ian, Do you think we will ever see the adoption of a more feature rich server side language (like python) that can be embedded within html, like php? Why does php enjoy this unique position?

January 20, 2010 | Unregistered CommenterBrian Soule

While working on a java outofmemoryerror problem, I took a systematic approach. In this approach, first step is identifying possible causes and then eliminating them step by step. In the last step where the complex part of memory leak is analysed, this tip is really important. Here is the complete article - http://www.myhomepageindia.com/index.php/2010/02/09/investigating-java-lang-outofmemoryerror.html.

February 12, 2010 | Unregistered CommenterDeepak

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>