JavaSniffer builds upon the textual output from "hprof", Suns default implementation of a profiler listening to the JVMPI, the "Java Virtual Machine Profiler Interface". With a bit of pratice this textual output can also be used by the programmer to determine which object is a loitering object in the first place. If you know which object is loitering the next step is to find out why it is loitering, i.e. which live objects still have references to it. You can do so by examining the whole heap graph either by manually searching the textual output of "hprof" or using high priced tools like the JProbe Memory Debugger from Sitraka. The problem is, both are of very little help when the graph gets big and there are a lot of references. JavaSniffer tries to solve the problem by finding the root objects of the heap and recording the paths from the loitering object to these roots. This decreases the amount of data to consider significantly without dropping any useful information.
JavaSniffer needs as arguments the file containing the textual output from "hprof" and the address of the loitering object. It then parses the file, generates the heap memory graph and does a reverse breadth first search to the root objects (this means it might need quite a lot of memory). Besides some statistic stuff the main output are the paths it has found.
They are printed in the syntax: <name of referencing object in hprof style> || \/ <name of variable that holds reference> || \/ <name of referenced object in hprof style> Consider this example: root1 || \/ refVar1 || \/ object2 || \/ refVar2 || \/ loiterungObject
It describes the path from the root object "root1" to the loitering object "loiterungObject". "root1" has a member variable "refVar1" that points to "object2". This in turn has a member variable "refVar2" referencing the loitering object.
To make the loitering object garbage collectable we need to break at least one of the references in our program code. If there is more than one path from the loitering object to a root we need to remove one reference per path.
JavaSniffer: Copyright (c) 2003-2004, Oliver Zeigermann
December 2003