Recently in Flex, you need to encapsulate an event sheet Pojo object for presentation. Think of more than 6,000 records in the database, the encapsulation is sure to occupy a lot of memory, and the Flex object is completely passed from the Java object to encapsulate again, that is, twice times the amount of memory. So with the title in mind, how much memory does a Java Pojo object actually occupy?
As shown in the following question:
Object O=new Object ():
In Java, a hollow object occupies eight bytes, and the object's reference is four bytes. So the above statement occupies a space of 4byte+8byte=12byte.java memory is allocated in multiples of 8, so the allocated memory is 16byte.
As an example:
Class o{
int i;
BYTE J;
String s;
}
The size of the memory it occupies is empty object (8) +int (4) +byte (1) +string Reference (4) =17byte, because if 8 is an integer multiple, it occupies a size of 24byte.
Of course, if there are other objects in the class, it is also necessary to calculate the space of other objects, other object algorithms, as shown in the above object.
How much memory space a Java object occupies