« February 2006 »
SunMonTueWedThuFriSat
   
1
2
3
4
6
7
8
9
10
12
13
14
16
18
19
22
23
25
26
27
28
    
       
Today
XML

Blog::Navigation

GetJava Download Button
Get the Source
Personal Blog

Blog::Referers

Today's Page Hits: 91

Powered by Roller Weblogger.
« Previous day (Feb 15, 2006) | Main | Next day (Feb 17, 2006) »
20060217 Friday February 17, 2006

Yes, there is also fifth way :-)

In my previous post on heap histograms, I missed another way to view histogram. Thanks to Alan Bateman for pointing out the same in his comment! Here it is:

The fifth way! Use the heapViewer demo JVM TI agent shipped with JDK.


On Windows:
    java -agentpath:%JAVA_HOME%\demo\jvmti\heapViewer\lib\heapViewer.dll MainClass

On Unix:
    java -agentpath:$JAVA_HOME/demo/jvmti/heapViewer/lib/libheapViewer.so MainClass

where JAVA_HOME is the directory where your JDK is installed. This heapViewer agent prints histogram whenever SIGQUIT signal is sent to the Java process or when the Java process exits (normal exit or Ctrl-C). Sample output of the heapViewer agent is in this blog entry by Alan.

You can look at the source code of this heapViewer agent under $JAVA_HOME/demo/jvmti/heapViewer/src directory. If you want to learn about JVM TI agents, you may want to read Kelly's blog on agents.



( Feb 17 2006, 08:24:17 PM IST ) Permalink Comments [2] del.icio.us | furl | simpy | slashdot | technorati | digg

4 ways to view Java heap histogram with Mustang

With Mustang (Java SE 6), there are atleast 4 ways to get histogram of Java heap:

  1. Using jmap
    
        jmap -histo <pid-of-java-process>
    
    
  2. Using -XX:+PrintClassHistogram option when starting the java application. With this option, whenever SIGQUIT signal is sent (pressing Ctrl-\ on Unix, Ctrl-Break on Windows), heap histogram is printed.
  3. Using jmap tool to dump heap dump and viewing the same using jhat
    
        jmap -dump:format=b,file=heap.bin <pid-of-java-process>
        jhat heap.bin
    
    
    When jhat is started, visit the URL "http://localhost:7000/" and click on "Show heap histogram" link to view the histogram.
  4. Using DTrace with Mustang. The following D-script accumulates count and total size in aggregates -- which can be printed on END probe. This script uses object-alloc probe. More details on Mustang built-in DTrace probes can be found in Keith's blog
    
        hotspot$1:::object-alloc {
            self->str_ptr = (char*) copyin(arg1, arg2+1);
            self->str_ptr[arg2] = '\0';
            self->classname = (string) self->str_ptr;
            @allocs_count[self->classname] = count();
            @allocs_size[self->classname] = sum(arg3);
        }
    



( Feb 17 2006, 03:39:07 PM IST ) Permalink Comments [1] del.icio.us | furl | simpy | slashdot | technorati | digg

Copyright (C) 2005, A. Sundararajan's Weblog