Package com.simplicite.util.tools
Class SizeOfTool
- java.lang.Object
-
- com.simplicite.util.tools.SizeOfTool
-
public class SizeOfTool extends java.lang.Object
Toolbox to manage size of objects,
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SizeOfTool.CacheMetric
Cache metrics
-
Field Summary
Fields Modifier and Type Field Description static SizeOfTool
INSTANCE
static int
SIZE_CLASS
static int
SIZE_POINTER
-
Constructor Summary
Constructors Constructor Description SizeOfTool()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<SizeOfTool.CacheMetric>
getMetrics(long limit, boolean fast)
static java.util.List<SizeOfTool.CacheMetric>
getMetrics(com.simplicite.util.engine.MemoryCache cache, long limit, boolean fast, java.util.List<SizeOfTool.CacheMetric> result)
Overview of object cache in memorystatic java.util.List<SizeOfTool.CacheMetric>
getObjectMetrics(long limit, boolean fast)
static long
getObjectSize(java.lang.Object o, boolean fast)
Get the memory used by the objectstatic int
getPrimitiveFieldSize(java.lang.Class<?> c)
static java.util.List<SizeOfTool.CacheMetric>
getProcessMetrics(long limit, boolean fast)
static long
roundUp(long size, int round)
static long
sizeOf(java.io.Serializable o)
Get the size of the serialized object (fast approximation of object size)static long
sizeOf(java.lang.Object obj, boolean deep)
Object size approximation (slow)static long
sizeOf(java.lang.Object obj, boolean deep, boolean trace)
Object size approximation
-
-
-
Field Detail
-
INSTANCE
public static final SizeOfTool INSTANCE
-
SIZE_POINTER
public static final int SIZE_POINTER
- See Also:
- Constant Field Values
-
SIZE_CLASS
public static final int SIZE_CLASS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getMetrics
public static java.util.List<SizeOfTool.CacheMetric> getMetrics(com.simplicite.util.engine.MemoryCache cache, long limit, boolean fast, java.util.List<SizeOfTool.CacheMetric> result)
Overview of object cache in memory- Parameters:
limit
- limit return size (0=no limit)fast
- use serialization method, faster than fields reflection/inspection- Returns:
- list of memory approximation sorted by sizes
-
getObjectSize
public static long getObjectSize(java.lang.Object o, boolean fast)
Get the memory used by the object
- Parameters:
o
- Any objectfast
- based on serialization (fast approximation) or reflection (slower)- Returns:
- memory size (Bytes)
-
getObjectMetrics
public static java.util.List<SizeOfTool.CacheMetric> getObjectMetrics(long limit, boolean fast)
-
getProcessMetrics
public static java.util.List<SizeOfTool.CacheMetric> getProcessMetrics(long limit, boolean fast)
-
getMetrics
public static java.util.List<SizeOfTool.CacheMetric> getMetrics(long limit, boolean fast)
-
sizeOf
public static long sizeOf(java.io.Serializable o)
Get the size of the serialized object (fast approximation of object size)
- Returns:
- memory size approximation (Bytes), based on serialized objects
-
sizeOf
public static long sizeOf(java.lang.Object obj, boolean deep)
Object size approximation (slow)- Parameters:
obj
- Any objectdeep
- Deep count- Returns:
- Size approximation based on fields reflection
-
sizeOf
public static long sizeOf(java.lang.Object obj, boolean deep, boolean trace)
Object size approximation- Parameters:
obj
- Any objectdeep
- Deep counttrace
- Log object structure- Returns:
- Size approximation based on fields reflection
-
roundUp
public static long roundUp(long size, int round)
-
getPrimitiveFieldSize
public static int getPrimitiveFieldSize(java.lang.Class<?> c)
-
-