public class ObjectSizeCalculator extends Object
| Constructor and Description |
|---|
ObjectSizeCalculator(MemoryLayoutSpecification memoryLayoutSpecification)
Creates an object size calculator that can calculate object sizes for a given
memoryLayoutSpecification. |
| Modifier and Type | Method and Description |
|---|---|
long |
calculateObjectSize(Object obj)
Given an object, returns the total allocated size, in bytes, of the object and all other objects reachable from it.
|
static long |
getObjectSize(Object obj)
Given an object, returns the total allocated size, in bytes, of the object and all other objects reachable from it.
|
public ObjectSizeCalculator(MemoryLayoutSpecification memoryLayoutSpecification)
memoryLayoutSpecification.memoryLayoutSpecification - a description of the JVM memory layout.public static long getObjectSize(Object obj) throws UnsupportedOperationException
UnsupportedOperationException;obj - the object; can be null. Passing in a Class object doesn't do anything special, it
measures the size of all objects reachable through it (which will include its class loader, and by
extension, all other Class objects loaded by the same loader, and all the parent class loaders). It doesn't
provide the size of the static fields in the JVM class that the Class object represents.UnsupportedOperationException - if the current vm memory layout cannot be detected.public long calculateObjectSize(Object obj)
obj - the object; can be null. Passing in a Class object doesn't do anything special, it
measures the size of all objects reachable through it (which will include its class loader, and by
extension, all other Class objects loaded by the same loader, and all the parent class loaders). It doesn't
provide the size of the static fields in the JVM class that the Class object represents.Copyright © 2021 The Apache Software Foundation. All rights reserved.