Could anyone make me understand the term "object header" and "padding" in java?
class A{
int a;
}
what "object header" and "padding" would be here ?
Could anyone make me understand the term "object header" and "padding" in java?
class A{
int a;
}
what "object header" and "padding" would be here ?
"Padding" is the tendency of objects in Java to be a multiple of 8 due to memory alignment: Why do Java objects have to be a multiple of 8?
All objects in Java contain an "object header" with a bit of extra overhead information (causing them to take up a little extra space): What is in java object header
So in your example, there would be space taken up by the header for class A along with the space needed to hold it's field int a. If these two values did not add up to a multiple of 8, extra space would be added to the memory location so that it was a multiple of 8, and therefore properly aligned in memory.