org.apache.spark.util
Class SizeEstimator

Object
  extended by org.apache.spark.util.SizeEstimator
All Implemented Interfaces:
Logging

public class SizeEstimator
extends Object
implements Logging

:: DeveloperApi :: Estimates the sizes of Java objects (number of bytes of memory they occupy), for use in memory-aware caches.

Based on the following JavaWorld article: http://www.javaworld.com/javaworld/javaqa/2003-12/02-qa-1226-sizeof.html


Constructor Summary
SizeEstimator()
           
 
Method Summary
static long estimate(Object obj)
          Estimate the number of bytes that the given object takes up on the JVM heap.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.spark.Logging
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
 

Constructor Detail

SizeEstimator

public SizeEstimator()
Method Detail

estimate

public static long estimate(Object obj)
Estimate the number of bytes that the given object takes up on the JVM heap. The estimate includes space taken up by objects referenced by the given object, their references, and so on and so forth.

This is useful for determining the amount of heap space a broadcast variable will occupy on each executor or the amount of space each object will take when caching objects in deserialized form. This is not the same as the serialized size of the object, which will typically be much smaller.

Parameters:
obj - (undocumented)
Returns:
(undocumented)