### Question:
SizeOf { public SizeOf(SizeOfFilter fieldFilter, boolean caching) { ObjectGraphWalker.Visitor visitor; if (caching) { visitor = new CachingSizeOfVisitor(); } else { visitor = new SizeOfVisitor(); } this.walker = new ObjectGraphWalker(visitor, fieldFilter); } SizeOf(SizeOfFilter fieldFilter, boolean caching); long sizeOf(Object obj); Size deepSizeOf(int maxDepth, boolean abortWhenMaxDepthExceeded, Object... obj);  }### Answer:
@Test public void testSizeOf() throws Exception { Assume.assumeThat(CURRENT_JVM_INFORMATION.getMinimumObjectSize(), is(CURRENT_JVM_INFORMATION.getObjectAlignment())); SizeOf sizeOf = new CrossCheckingSizeOf(); if (System.getProperty("java.version").startsWith("1.5")) { if (IS_64_BIT) { verify64bitSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(136L)); } else { verify32bitSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(80L)); } } else { if (IS_64_BIT) { if (IS_JROCKIT) { verify64bitJRockit4GBCompressedRefsSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(144L)); } else if (IS_IBM) { verify64bitIBMSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(224L)); } else if (COMPRESSED_OOPS) { verify64bitCompressedOopsSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(112L)); } else { verify64bitSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(176L)); } } else if (IS_IBM) { verify32bitIBMSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(112L)); } else if (IS_JROCKIT) { verify32bitJRockitSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(144L)); } else { verify32bitSizes(sizeOf); assertThat(deepSizeOf(sizeOf, new ReentrantReadWriteLock()), is(104L)); } } List<Object> list1 = new ArrayList<Object>(); List<Object> list2 = new ArrayList<Object>(); Object someInstance = new Object(); list1.add(someInstance); list2.add(someInstance); assertThat(deepSizeOf(sizeOf, list1), equalTo(deepSizeOf(sizeOf, list2))); assertThat(deepSizeOf(sizeOf, list1, list2) < (deepSizeOf(sizeOf, list1) + deepSizeOf(sizeOf, list2)), is(true)); list2.add(new Object()); assertThat(deepSizeOf(sizeOf, list2) > deepSizeOf(sizeOf, list1), is(true)); }