public class ObjectSizeCalculator extends Object
| Constructor and Description |
|---|
ObjectSizeCalculator() |
| Modifier and Type | Method and Description |
|---|---|
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 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.Copyright © 2024 The Apache Software Foundation. All rights reserved.