public class ObjectSizes
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ObjectSizes.MemoryLayoutSpecification
Describes constant memory overheads for various constructs in a JVM
implementation.
|
Modifier and Type | Field and Description |
---|---|
static ObjectSizes.MemoryLayoutSpecification |
SPEC |
Constructor and Description |
---|
ObjectSizes() |
Modifier and Type | Method and Description |
---|---|
static long |
getArraySize(byte[] bytes)
Memory a byte array consumes
|
static long |
getArraySize(int length,
long elementSize)
Memory an array will consume
|
static long |
getFieldSize(long fieldsSize)
Memory a class consumes, including the object header and the size of the fields.
|
static int |
getReferenceSize() |
static long |
getSize(java.nio.ByteBuffer buffer)
Memory a byte buffer consumes
|
static long |
getSuperClassFieldSize(long fieldsSize)
Memory a super class consumes, given the primitive field sizes
|
static long |
measureDeep(java.lang.Object pojo) |
static long |
roundTo(long x,
int multiple) |
public static final ObjectSizes.MemoryLayoutSpecification SPEC
public static long getFieldSize(long fieldsSize)
fieldsSize
- Total size of the primitive fields of a classpublic static long getSuperClassFieldSize(long fieldsSize)
fieldsSize
- Total size of the primitive fields of the super classpublic static long getArraySize(int length, long elementSize)
length
- Number of elements in the arrayelementSize
- In-memory size of each element's primitive storedpublic static long getArraySize(byte[] bytes)
bytes
- byte array to get memory sizepublic static long getSize(java.nio.ByteBuffer buffer)
buffer
- ByteBuffer to calculate in memory sizepublic static long roundTo(long x, int multiple)
public static int getReferenceSize()
public static long measureDeep(java.lang.Object pojo)
Copyright © 2014 The Apache Software Foundation