Package gw.util.perf.objectsize
Class ObjectSizeUtil
java.lang.Object
gw.util.perf.objectsize.ObjectSizeUtil
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static DecimalFormat
private static final IObjectSizeFilter
private static final String
private static final Map
static boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectSize
deepSizeOf
(Object obj) static ObjectSize
deepSizeOf
(Object obj, IObjectSizeFilter filter, int maxObjects) Calculates full size of object iterating over its hierarchy graph.private static long
static int
getFieldSize
(Class clazz) static int
private static long
internalSizeOf
(ObjectSizeUtil.ObjectEntry entry, Stack<ObjectSizeUtil.ObjectEntry> stack, Map<Object, Object> visited, IObjectSizeFilter filter, String indent) static void
private static long
roundUpToNearestEightBytes
(long result) private static boolean
skipField
(Field field, IObjectSizeFilter filter) private static boolean
skipObject
(Object obj, Map<Object, Object> visited, IObjectSizeFilter filter)
-
Field Details
-
VERBOSE
public static boolean VERBOSE -
INDENT
- See Also:
-
DEFAULT_FILTER
-
decimalFormat
-
primitiveSizes
-
-
Constructor Details
-
ObjectSizeUtil
public ObjectSizeUtil()
-
-
Method Details
-
getFieldSize
-
getPointerSize
public static int getPointerSize() -
deepSizeOf
Calculates full size of object iterating over its hierarchy graph.- Parameters:
obj
- object to calculate size offilter
- the filter used to ignore fields or objectsmaxObjects
- the max numbers of objects to traverse- Returns:
- object size
- Throws:
Exception
-
deepSizeOf
-
skipObject
-
skipField
-
getArrayShallowSize
-
internalSizeOf
private static long internalSizeOf(ObjectSizeUtil.ObjectEntry entry, Stack<ObjectSizeUtil.ObjectEntry> stack, Map<Object, Object> visited, IObjectSizeFilter filter, String indent) -
roundUpToNearestEightBytes
private static long roundUpToNearestEightBytes(long result) -
main
- Throws:
Exception
-