sclass SizeEstimate { new Map shallowFieldSizes; new Set complexFields; new Map complexFieldSizes; } static SizeEstimate estimateWebBotSize(O o) { new SizeEstimate se; Collection fields = fields(o); for (S field : fields) { if (sizeCalculation_shouldIgnoreProgramField(field)) continue; O value = get(o, field); if (value == null) continue; Class type = value.getClass(); if (isBoxedType(type) || isPrimitiveArray(value)) continue with se.shallowFieldSizes.put(field, deepObjectSize(value)); se.complexFields.add(field); } O[] array = asObjectArray(getFields(o, se.complexFields)); new guessDeepObjectSize_recursive_Data data; data.seen.add(o); ret guessDeepObjectSize_recursive(data, array)-inMemorySizeOfArray(array); }