Index: hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java (revision 1393057) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java (working copy) @@ -50,7 +50,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.ClassSize; import org.junit.experimental.categories.Category; -import org.junit.Before; +import org.junit.BeforeClass; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; @@ -65,8 +65,8 @@ // BatchOperation, BatchUpdate, BlockIndex, Entry, Entry, HStoreKey // KeyValue, LruBlockCache, LruHashMap, Put, HLogKey - @Before - public void setUp() throws Exception { + @BeforeClass + public void beforeClass() throws Exception { // Print detail on jvm so we know what is different should below test fail. RuntimeMXBean b = ManagementFactory.getRuntimeMXBean(); LOG.info("name=" + b.getName()); Index: hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java =================================================================== --- hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java (revision 1393057) +++ hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java (working copy) @@ -23,6 +23,8 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.util.concurrent.ConcurrentHashMap; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; @@ -145,10 +147,14 @@ TREEMAP = align(OBJECT + (2 * Bytes.SIZEOF_INT) + align(7 * REFERENCE)); - STRING = align(OBJECT + ARRAY + REFERENCE + ((JDK7? 2: 3) * Bytes.SIZEOF_INT)); + // STRING is different size in jdk6 and jdk7. Just use what we estimate as size rather than + // have a conditional on whether jdk7. + STRING = (int) estimateBase(String.class, false); - CONCURRENT_HASHMAP = align(((JDK7? 3: 2) * Bytes.SIZEOF_INT) + ARRAY + - (6 * REFERENCE) + OBJECT); + // CONCURRENT_HASHMAP is different size in jdk6 and jdk7; it looks like its different between + // 23.6-b03 and 23.0-b21. Just use what we estimate as size rather than have a conditional on + // whether jdk7. + CONCURRENT_HASHMAP = (int) estimateBase(ConcurrentHashMap.class, false); CONCURRENT_HASHMAP_ENTRY = align(REFERENCE + OBJECT + (3 * REFERENCE) + (2 * Bytes.SIZEOF_INT));