LTM - (Object) Life Time Monitoring

Summary

LTM is a Java tool for giving an overview of the life time of instances. It is based on a method described by Jack Shirazi and uses PhantomReferences and a modified java.lang.Object. By using it you are able to track object creation and garbage collection and count the number of currently life instances per class. The collected data can be viewed using a simple graphical viewer. LTM is described in detail in my article Überwachung der Anzahl aktiver Objekte in JavaSPEKTRUM, 1/2006.

Note that professional profiling tools are much more powerful and reliable. LTM was only developed because we could not suffer the overhead of a full blown memory snapshot algorithm.

Installation

To install LTM, simply extract the ltm-*.zip and put it into your bootclasspath with LTM.jar. LTM is JDK 1.3 compliant and does not depend on any other libraries. When using another JRE than 1.4, you will have to modify your java.lang.Object as well and put if before LTM.jar into your bootclasspath:

   // --- code added to object ---
   public Object() {
      if (at.herold.test.objlifetime.MonitoringFlag.monitoring) {
        at.herold.test.objlifetime.ObjectLifetimeMonitoring.monitor(this);
      }
   }
   // --- code added to object ---

Usage

  1. Start your application with LTM enabled
    java -Xbootclasspath/p:LTM.jar
         -classpath <your application's classpath>
         at.herold.test.objlifetime.ObjectLifetimeMonitoring
         s
         <your application's main class>
         <your application's parameters if any>
    
  2. Tell the LTM to start collecting data with "java -jar LTM.jar start" on the same machine running the application. This enables the counting of objects.
  3. To stop collecting data run "java -jar LTM.jar stop". The application will continue to run normally.
  4. To save the recently collected raw data use "java -jar LTM.jar save". This saves the raw data using a constant file name.
  5. You can view the "java -jar LTMViewer.jar <raw file>". This loads, analyses and displays the object lifetime statistics. An JPG image is saved as well.

Packages

In case you want to add or change something, there are the following packages:

License Agreement

LTM is Open Source under the GPL license.

Version History