Class ClassSize


  • 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 Detail

      • ARRAY

        public static final int ARRAY
        Array overhead
      • BYTE_BUFFER

        public static final int BYTE_BUFFER
        Overhead for ByteBuffer
      • 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
      • 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
      • ATOMIC_INTEGER

        public static final int ATOMIC_INTEGER
        Overhead for AtomicInteger
    • Constructor Detail

      • ClassSize

        public ClassSize()
    • Method Detail

      • 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