public class SizeEstimator extends Object
Modifier and Type | Method and Description |
---|---|
static SizeEstimator |
getInstance()
Returns the single existing SizeEstimator instance.
|
protected ArrayList<Field> |
getNonStaticFields(Class<?> clazz)
Returns an array list of all the non-static fields of a class including the non-static fields of all of its ancestors.
|
boolean |
isInstanceSizeConstant(Class<?> clazz)
Returns whether all instances of the specified class must have the same memory requirements.
|
long |
sizeOf(Class<?> clazz)
Statically estimates the size of an instance of the class.
|
long |
sizeOf(Object o)
Estimates the size of an object including the sizes of all objects referenced in the object graph.
|
public static SizeEstimator getInstance()
protected ArrayList<Field> getNonStaticFields(Class<?> clazz)
clazz
- The class.public boolean isInstanceSizeConstant(Class<?> clazz)
clazz
- The class.public long sizeOf(Object o)
o
- The object.public long sizeOf(Class<?> clazz)
isInstanceSizeConstant
returns true, i.e. all the non-static fields of the class and its ancestors are primitives. The non-primitive
non-static fields are assumed to be null pointers.clazz
- The class.Copyright © 2020. All rights reserved.