Hello,
I would like to ask about Memory Overhead in java,
I have a large ArrayList (61,770 items), and trying to calculate the amount of memory taken by each item (counting the object and its ArrayList entry),
by profiling the app i get that after all the data is loaded, the heap takes ~ 25Mb.
when the ArrayList has only 2 items the heap takes ~1Mb , so roughly:
(24*1024*1024)/61,768 = 407 bytes.
however, when i count the fields of the each object, i get 148 bytes(not including the ArrayList, and assuming int=4,float=4,reference=4), I am curious to know where did all of those extra bytes came from...
i can guess that since the objects I store in the ArrayList are implementing an interface, they store extra values, maybe the VM stores a 4byte function pointer for each implemented method?
the interface they implement have 20 functions so thats 80 more bytes, totaling 228 bytes, still not close to the 400 bytes measured.
any help would be appreciated.