Java Memory Usage

What would be the amount of memory used in heap when  you create an “empty” class and then add a int member to  it?

Answer:8 bytes for the class and 4 for the int. But since memory blocks are used as 8 bytes, total memory allocated would be 16 bytes.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s