Size of Integer objects in JAVA

This is a memory design of an object of the class below that stores N elements of type Integer. What I don't quite understand is the memory storage for Integer objects. Hasn't it been taken care of already? And if so why is it 24 bytes?

I mean 24N for Integer objects.

public class GenericMysteryBox<Item> 
{        //       16 (object overhead)
 private int N;                            //        4 (int)
 private Item[] items;                     //        8 (reference to array)
                                          //  8N + 24 (array of Integer references)
                                          //      24N (Integer objects)
...                                                 4 (padding to round up to a multiple of 8)
}          

      

+3


source to share





All Articles