org.apache.hadoop.hbase.util
Class ClassSize

java.lang.Object
  extended by org.apache.hadoop.hbase.util.ClassSize

@InterfaceAudience.Private
public class ClassSize
extends Object

Class for determining the "size" of a class, an attempt to calculate the actual bytes that an object of this class will occupy in memory The core of this class is taken from the Derby project


Field Summary
static int ARRAY
          Array overhead
static int ARRAYLIST
          Overhead for ArrayList(0)
static int ATOMIC_BOOLEAN
          Overhead for AtomicBoolean
static int ATOMIC_INTEGER
          Overhead for AtomicInteger
static int ATOMIC_LONG
          Overhead for AtomicLong
static int BYTE_BUFFER
          Overhead for ByteBuffer
static int CONCURRENT_HASHMAP
          Overhead for ConcurrentHashMap
static int CONCURRENT_HASHMAP_ENTRY
          Overhead for ConcurrentHashMap.Entry
static int CONCURRENT_HASHMAP_SEGMENT
          Overhead for ConcurrentHashMap.Segment
static int CONCURRENT_SKIPLISTMAP
          Overhead for ConcurrentSkipListMap
static int CONCURRENT_SKIPLISTMAP_ENTRY
          Overhead for ConcurrentSkipListMap Entry
static int COPYONWRITE_ARRAYLIST
          Overhead for CopyOnWriteArrayList
static int COPYONWRITE_ARRAYSET
          Overhead for CopyOnWriteArraySet
static int INTEGER
          Overhead for an Integer
static int KEYVALUE_SKIPLIST_SET
          Overhead for KeyValueSkipListSet
static int MAP_ENTRY
          Overhead for entry in map
static int OBJECT
          Object overhead is minimum 2 * reference size (8 bytes on 64-bit)
static int REENTRANT_LOCK
          Overhead for ReentrantReadWriteLock
static int REFERENCE
          Reference size is 8 bytes on 64-bit, 4 bytes on 32-bit
static int STRING
          String overhead
static int TIMERANGE
          Overhead for timerange
static int TIMERANGE_TRACKER
          Overhead for TimeRangeTracker
static int TREEMAP
          Overhead for TreeMap
 
Constructor Summary
ClassSize()
           
 
Method Summary
static int align(int num)
          Aligns a number to 8.
static long align(long num)
          Aligns a number to 8.
static long estimateBase(Class cl, boolean debug)
          Estimate the static space taken up by the fields of a class.
static boolean is32BitJVM()
          Determines if we are running in a 32-bit JVM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARRAY

public static final int ARRAY
Array overhead


ARRAYLIST

public static final int ARRAYLIST
Overhead for ArrayList(0)


BYTE_BUFFER

public static final int BYTE_BUFFER
Overhead for ByteBuffer


INTEGER

public static final int INTEGER
Overhead for an Integer


MAP_ENTRY

public static final int MAP_ENTRY
Overhead for entry in map


OBJECT

public static final int OBJECT
Object overhead is minimum 2 * reference size (8 bytes on 64-bit)


REFERENCE

public static final int REFERENCE
Reference size is 8 bytes on 64-bit, 4 bytes on 32-bit


STRING

public static final int STRING
String overhead


TREEMAP

public static final int TREEMAP
Overhead for TreeMap


CONCURRENT_HASHMAP

public static final int CONCURRENT_HASHMAP
Overhead for ConcurrentHashMap


CONCURRENT_HASHMAP_ENTRY

public static final int CONCURRENT_HASHMAP_ENTRY
Overhead for ConcurrentHashMap.Entry


CONCURRENT_HASHMAP_SEGMENT

public static final int CONCURRENT_HASHMAP_SEGMENT
Overhead for ConcurrentHashMap.Segment


CONCURRENT_SKIPLISTMAP

public static final int CONCURRENT_SKIPLISTMAP
Overhead for ConcurrentSkipListMap


CONCURRENT_SKIPLISTMAP_ENTRY

public static final int CONCURRENT_SKIPLISTMAP_ENTRY
Overhead for ConcurrentSkipListMap Entry


REENTRANT_LOCK

public static final int REENTRANT_LOCK
Overhead for ReentrantReadWriteLock


ATOMIC_LONG

public static final int ATOMIC_LONG
Overhead for AtomicLong


ATOMIC_INTEGER

public static final int ATOMIC_INTEGER
Overhead for AtomicInteger


ATOMIC_BOOLEAN

public static final int ATOMIC_BOOLEAN
Overhead for AtomicBoolean


COPYONWRITE_ARRAYSET

public static final int COPYONWRITE_ARRAYSET
Overhead for CopyOnWriteArraySet


COPYONWRITE_ARRAYLIST

public static final int COPYONWRITE_ARRAYLIST
Overhead for CopyOnWriteArrayList


TIMERANGE

public static final int TIMERANGE
Overhead for timerange


TIMERANGE_TRACKER

public static final int TIMERANGE_TRACKER
Overhead for TimeRangeTracker


KEYVALUE_SKIPLIST_SET

public static final int KEYVALUE_SKIPLIST_SET
Overhead for KeyValueSkipListSet

Constructor Detail

ClassSize

public ClassSize()
Method Detail

estimateBase

public static long estimateBase(Class cl,
                                boolean debug)
Estimate the static space taken up by the fields of a class. This includes the space taken up by by references (the pointer) but not by the referenced object. So the estimated size of an array field does not depend on the size of the array. Similarly the size of an object (reference) field does not depend on the object.

Parameters:
cl - class
debug - debug flag
Returns:
the size estimate in bytes.

align

public static int align(int num)
Aligns a number to 8.

Parameters:
num - number to align to 8
Returns:
smallest number >= input that is a multiple of 8

align

public static long align(long num)
Aligns a number to 8.

Parameters:
num - number to align to 8
Returns:
smallest number >= input that is a multiple of 8

is32BitJVM

public static boolean is32BitJVM()
Determines if we are running in a 32-bit JVM. Some unit tests need to know this too.



Copyright © 2015 The Apache Software Foundation. All Rights Reserved.