Top Description Inners Constructors Methods
com.carrotsearch.sizeof

public Class ObjectTree

extends Object
Class Inheritance
Imports
java.io.PrintWriter, .StringWriter, java.lang.reflect.*, java.util.*, com.carrotsearch.sizeof.RamUsageEstimator

Dumps retained and shallow memory taken by an object and its reference hierarchy. This could be improved in a number of ways but works for debugging and "live" object monitoring. For static heap analyses a real performance monitor like YourKit is much better (and accurate?).
See Also
dump(PrintWriter, Object), dump(Object)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
dump(PrintWriter pw, Object root)

Dump the object tree to a PrintWriter.

public static String
dump(Object root)

Dump the object tree to a String.

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ObjectTreeback to summary
public ObjectTree()

Method Detail

dumpback to summary
public static void dump(PrintWriter pw, Object root)

Dump the object tree to a PrintWriter.

dumpback to summary
public static String dump(Object root)

Dump the object tree to a String.

printTreeback to summary
private static void printTree(StringBuilder prefix, StringBuilder line, PrintWriter pw, ObjectTree.Node node)
com.carrotsearch.sizeof back to summary

private Class ObjectTree.Node

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private List<ObjectTree.Node>
private long
private String
private long

Constructor Summary

AccessConstructor and Description
public
Node(String name, Object delegate)

Method Summary

Modifier and TypeMethod and Description
private void
public static ObjectTree.Node
create(Object delegate)

Factory create method.

public static ObjectTree.Node
create(String prefix, Object delegate, IdentityHashMap<Object, Integer> seen)

Factory create method.

public List<ObjectTree.Node>
public String
public boolean
private static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

childrenback to summary
private List<ObjectTree.Node> children
deepSizeback to summary
private long deepSize
nameback to summary
private String name
shallowSizeback to summary
private long shallowSize

Constructor Detail

Nodeback to summary
public Node(String name, Object delegate)

Method Detail

addChildback to summary
private void addChild(ObjectTree.Node node)
createback to summary
public static ObjectTree.Node create(Object delegate)

Factory create method.

createback to summary
public static ObjectTree.Node create(String prefix, Object delegate, IdentityHashMap<Object, Integer> seen)

Factory create method.

getChildrenback to summary
public List<ObjectTree.Node> getChildren()
getNameback to summary
public String getName()
hasChildrenback to summary
public boolean hasChildren()
uniqueNameback to summary
private static String uniqueName(Object t, IdentityHashMap<Object, Integer> seen)