Static fields and heap usage [message #2029] |
Wed, 30 April 2008 12:26  |
Eclipse User |
|
|
|
Hi,
I am using MAT to analyse an application which uses GEF (http://www.eclipse.org/gef).
For each org.eclipse.draw2d.geometry.Rectangle instance the "Shallow Heap" and "Retained Heap" indicate both 24.
Below is the fields of Rectangle class :
/** the X value */
public int x;
/** the Y value */
public int y;
/** the width*/
public int width;
/** the height */
public int height;
/**A singleton for use in short calculations. Use to avoid newing unnecessary objects.*/
public static final Rectangle SINGLETON = new Rectangle();
static final long serialVersionUID = 1;
How is made the calculation ?
24 = 4 integers * 4 bytes + 1 long * 8 bytes (which seems me false)
24 = 4 integers * 4 bytes + methods and virtual methods table
24 = something else
Thanks for your answers,
Regards,
Mariot
|
|
|
|
Re: Static fields and heap usage [message #2057 is a reply to message #2043] |
Fri, 02 May 2008 03:10  |
Eclipse User |
|
|
|
Hi Andreas,
Thanks for the clear explanation.
Best regards,
Mariot
Andreas Buchen wrote :
> Hi Mariot,
>
> the size of java.lang.Object is 2 times the identifier size (32 or 64 bit).
>
> Assuming a 32bit VM, this means for the draw2d.geometry.Rectangle:
> 24 = size of java.lang.Object (8) + 4 Integers á 4 bytes
>
> Just in case you are wondering a/b other objects:
> Object sizes are aligned up to a multiple of 8. That means a class A
> with just a byte field has a size of 16 (8 bytes object header from
> java.lang.Object + 1 byte field + 7 bytes alignment). This alignment can
> occur at every inheritance level: class B extending class A and again
> only declaring one byte field would waste a total of 14 bytes.
>
>
> Kind regards,
>
> Andreas.
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03339 seconds