Posted By:
Claus_Rasmussen
Posted On:
Monday, June 18, 2001 03:34 AM
Is there is a way to see how many bytes an object instance takes up in the memory?
E.g.
String[] myStringArray = {"1", "2", "3"};
To my knowledge the instance
myStringArray
would take up 3 x 16 bytes = 48 bytes since Java uses Unicode were each character is represented by 16 bytes.
But is there any way to retrieve this byte count through a method call? What if the object contains references to other objects? Can there memory usage be calculated as well?