Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Memory Analyzer (MAT) » Static fields and heap usage
Static fields and heap usage [message #2029] Wed, 30 April 2008 16:26 Go to next message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
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 #2043 is a reply to message #2029] Thu, 01 May 2008 21:53 Go to previous messageGo to next message
Andreas Buchen is currently offline Andreas BuchenFriend
Messages: 123
Registered: July 2009
Senior Member
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.
Re: Static fields and heap usage [message #2057 is a reply to message #2043] Fri, 02 May 2008 07:10 Go to previous message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
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.
>
>
Previous Topic:Blog: Immortal Objects - Or: How to Find Memory Leaks
Next Topic:No application id has been found.
Goto Forum:
  


Current Time: Thu Apr 25 20:17:43 GMT 2024

Powered by FUDForum. Page generated in 0.02631 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top