Class UnsafeSizeOf


  • public class UnsafeSizeOf
    extends SizeOf
    Unsafe.theUnsafe based sizeOf measurement All constructors will throw UnsupportedOperationException if theUnsafe isn't accessible on this platform
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.slf4j.Logger LOGGER  
      private static sun.misc.Unsafe UNSAFE  
    • Constructor Summary

      Constructors 
      Constructor Description
      UnsafeSizeOf()
      Builds a new SizeOf that will not filter fields and will cache reflected fields
      UnsafeSizeOf​(SizeOfFilter filter)
      Builds a new SizeOf that will filter fields according to the provided filter and will cache reflected fields
      UnsafeSizeOf​(SizeOfFilter filter, boolean caching, boolean bypassFlyweight)
      Builds a new SizeOf that will filter fields according to the provided filter
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long sizeOf​(java.lang.Object obj)
      Calculates the size in memory (heap) of the instance passed in, not navigating the down graph
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • UNSAFE

        private static final sun.misc.Unsafe UNSAFE
    • Constructor Detail

      • UnsafeSizeOf

        public UnsafeSizeOf​(SizeOfFilter filter,
                            boolean caching,
                            boolean bypassFlyweight)
                     throws java.lang.UnsupportedOperationException
        Builds a new SizeOf that will filter fields according to the provided filter
        Parameters:
        filter - The filter to apply
        caching - whether to cache reflected fields
        bypassFlyweight - whether "Flyweight Objects" are to be ignored
        Throws:
        java.lang.UnsupportedOperationException - If Unsafe isn't accessible
        See Also:
        SizeOfFilter
    • Method Detail

      • sizeOf

        public long sizeOf​(java.lang.Object obj)
        Calculates the size in memory (heap) of the instance passed in, not navigating the down graph
        Specified by:
        sizeOf in class SizeOf
        Parameters:
        obj - the object to measure the size of
        Returns:
        the object size in memory in bytes