You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2009/02/26 19:21:50 UTC

svn commit: r748259 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/io/HeapSize.java

Author: stack
Date: Thu Feb 26 18:21:49 2009
New Revision: 748259

URL: http://svn.apache.org/viewvc?rev=748259&view=rev
Log:
HBASE-1188 Memory size of Java Objects - Make cacheable objects implement HeapSize

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/HeapSize.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=748259&r1=748258&r2=748259&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Feb 26 18:21:49 2009
@@ -63,6 +63,8 @@
                options show up (Erik Holstad via Stack)
    HBASE-1189  Changing the map type used internally for HbaseMapWritable
                (Erik Holstad via Stack)
+   HBASE-1188  Memory size of Java Objects - Make cacheable objects implement
+               HeapSize (Erik Holstad via Stack)
 
 Release 0.19.0 - 01/21/2009
   INCOMPATIBLE CHANGES

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/HeapSize.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/HeapSize.java?rev=748259&r1=748258&r2=748259&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/HeapSize.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/HeapSize.java Thu Feb 26 18:21:49 2009
@@ -25,9 +25,41 @@
  * probably do not account for 32 vs 64 bit nor for different VM implemenations.
  */
 public interface HeapSize {
+  
+  /** Reference size is 8 bytes on 64-bit, 4 bytes on 32-bit */
+  static final int REFERENCE = 8;
+  
+  /** Object overhead is minimum 2 * reference size (8 bytes on 64-bit) */
+  static final int OBJECT = 2 * REFERENCE;
+  
+  /**
+   * The following types are always allocated in blocks of 8 bytes (on 64bit)
+   * For example, if you have two ints in a class, it will use 8 bytes.
+   * If you have three ints in a class, it will use 16 bytes.
+   */
+  static final int SHORT = 4;
+  static final int INT = 4;
+  static final int FLOAT = 4;
+  static final int BOOLEAN = 4;
+  static final int CHAR = 4;
+  static final int BYTE = 1;
+  
+  /** These types are always 8 bytes */
+  static final int DOUBLE = 8;
+  static final int LONG = 8;
+  
+  /** Array overhead */
+  static final int BYTE_ARRAY = REFERENCE;
+  static final int ARRAY = 3 * REFERENCE;
+  static final int MULTI_ARRAY = (4 * REFERENCE) + ARRAY;
+  
+  static final int BLOCK_SIZE_TAX = 8;
+
+  
+  
   /**
    * @return Approximate 'exclusive deep size' of implementing object.  Includes
    * count of payload and hosting object sizings.
-   */
+  */
   public long heapSize();
-}
\ No newline at end of file
+}