org.apache.cassandra.utils

## Class ObjectSizes

- java.lang.Object
- - org.apache.cassandra.utils.ObjectSizes

    public class ObjectSizes
    extends java.lang.Object

Modified version of the code from. https://github.com/twitter/commons/blob/master /src/java/com/twitter/common/objectsize/ObjectSizeCalculator.java Difference is that we don't use reflection.

### Nested Class Summary

Nested Classes
`static interface` `ObjectSizes.MemoryLayoutSpecification` Describes constant memory overheads for various constructs in a JVM implementation.

### Field Summary

Fields
`static ObjectSizes.MemoryLayoutSpecification` `SPEC`

### Constructor Summary

Constructors
Constructor and Description
`ObjectSizes()`

### Method Summary

Methods
`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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### SPEC

    public static final ObjectSizes.MemoryLayoutSpecification SPEC

### Constructor Detail

#### ObjectSizes

    public ObjectSizes()

### Method Detail

#### getFieldSize

    public static long getFieldSize(long fieldsSize)

Memory a class consumes, including the object header and the size of the fields.

Parameters:
  `fieldsSize` - Total size of the primitive fields of a class
Returns:
  Total in-memory size of the class

#### getSuperClassFieldSize

    public static long getSuperClassFieldSize(long fieldsSize)

Memory a super class consumes, given the primitive field sizes

Parameters:
  `fieldsSize` - Total size of the primitive fields of the super class
Returns:
  Total additional in-memory that the super class takes up

#### getArraySize

    public static long getArraySize(int length,
                    long elementSize)

Memory an array will consume

Parameters:
  `length` - Number of elements in the array
  `elementSize` - In-memory size of each element's primitive stored
Returns:
  In-memory size of the array

#### getArraySize

    public static long getArraySize(byte[] bytes)

Memory a byte array consumes

Parameters:
  `bytes` - byte array to get memory size
Returns:
  In-memory size of the array

#### getSize

    public static long getSize(java.nio.ByteBuffer buffer)

Memory a byte buffer consumes

Parameters:
  `buffer` - ByteBuffer to calculate in memory size
Returns:
  Total in-memory size of the byte buffer

#### roundTo

    public static long roundTo(long x,
               int multiple)

#### getReferenceSize

    public static int getReferenceSize()

Returns:
  Memory a reference consumes on the current architecture.

#### measureDeep

    public static long measureDeep(java.lang.Object pojo)