Skip Headers
Oracle® Java Micro Edition Embedded Client Developer's Guide
Release 1.1.1
  Go To Table Of Contents


5 Diagnosing Memory Leaks

This chapter describes options for finding and diagnosing application memory leaks.

This chapter includes these topics:

5.1 VM Inspector and cvmsh

The VM inspector is a collection of utilities that report virtual machine state, including memory-related state, during execution. To use the VM inspector, you must run an Oracle Java Micro Edition Embedded Client binary that was built with CVM_INSPECTOR=true. To verify your build, run cvm with this option: -XbuildOptions.

cvmsh is a command-line front end that sends VM inspector commands to a running cvm process. Launch cvmsh and cvm as illustrated by the following simple example:

% cvm -cp cvmsh

For a description of the VM inspector and cvmsh, refer to:

5.2 jvmtihprof and jhat

jhat is a web-based Java heap analysis tool, which is described at To create the data for jhat to display, run a command like this on the target device:

% bin/cvm -Xbootclasspath/a:lib/java_crw_demo.jar  \ -agentlib:jvmtihprof=heap=dump,format=b -cp yourApp.jar yourMainMethod 

Your application must be in the Jar file designated by yourApp.jar. The command creates a heap dump in java.hprof.txt. To display the heap with jhat, copy java.hprof.txt to your host, then run this command:

% jhat java.hprof

The jhat command starts a web server on port 7000. View the data in a web browser with this URL: http://localhost:7000, then drill down into the objects that were dumped.