public void testSanity() { assertTrue(sizeOf(new String("test string")) > shallowSizeOfInstance(String.class)); Holder holder = new Holder(); holder.holder = new Holder("string2", 5000L); assertTrue(sizeOf(holder) > shallowSizeOfInstance(Holder.class)); assertTrue(sizeOf(holder) > sizeOf(holder.holder)); assertTrue(shallowSizeOfInstance(HolderSubclass.class) >= shallowSizeOfInstance(Holder.class)); assertTrue(shallowSizeOfInstance(Holder.class) == shallowSizeOfInstance(HolderSubclass2.class)); String[] strings = new String[] {new String("test string"), new String("hollow"), new String("catchmaster")}; assertTrue(sizeOf(strings) > shallowSizeOf(strings)); }
public void testReferenceSize() { if (!isSupportedJVM()) { System.err.println("WARN: Your JVM does not support certain Oracle/Sun extensions."); System.err.println(" Memory estimates may be inaccurate."); System.err.println(" Please report this to the Lucene mailing list."); System.err.println("JVM version: " + RamUsageEstimator.JVM_INFO_STRING); System.err.println("UnsupportedFeatures:"); for (JvmFeature f : RamUsageEstimator.getUnsupportedFeatures()) { System.err.print(" - " + f.toString()); if (f == RamUsageEstimator.JvmFeature.OBJECT_ALIGNMENT) { System.err.print( "; Please note: 32bit Oracle/Sun VMs don't allow exact OBJECT_ALIGNMENT retrieval, this is a known issue."); } System.err.println(); } } assertTrue(NUM_BYTES_OBJECT_REF == 4 || NUM_BYTES_OBJECT_REF == 8); if (!Constants.JRE_IS_64BIT) { assertEquals("For 32bit JVMs, reference size must always be 4?", 4, NUM_BYTES_OBJECT_REF); } }