public long getRetainedSizeInBytes()
    {
        // Under the hood, BitSet stores a long[] array of BitSet.size() bits
        return INSTANCE_SIZE + BITSET_INSTANCE_SIZE + SizeOf.sizeOfLongArray(bitSet.size() / Long.SIZE);
    }
@Test
    public static void testRetainedSize()
    {
        int instanceSizes = ClassLayout.parseClass(Bitmap.class).instanceSize() + ClassLayout.parseClass(BitSet.class).instanceSize();

        // The underlying BitSet stores a long[] array of size length / 64,
        // even though toBytes() returns a truncated array of bytes.
        Bitmap bitmap = new Bitmap(1024);
        assertEquals(bitmap.getRetainedSizeInBytes(), instanceSizes + SizeOf.sizeOfLongArray(1024 / 64));
    }