Oracle® Java Micro Edition Embedded Client Developer's Guide Release 1.1.1 E20632-03 |
|
![]() Previous |
This chapter describes options for finding and diagnosing application memory leaks.
This chapter includes these topics:
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 testclasses.zip cvmsh
For a description of the VM inspector and cvmsh
, refer to:
jhat
is a web-based Java heap analysis tool, which is described at http://download.oracle.com/javase/6/docs/technotes/tools/share/jhat.html
. 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.