java.lang.Runtime class has a method* freeMemory
<http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#freeMemory%28%29>()*
which returns the amount of free memory

in the JVM. You can call this method before creating an object and
after creating an object.


On Wed, Nov 25, 2009 at 4:04 PM, daizi sheng <[email protected]> wrote:

> java normally pre-alloc much memory and so you have no way to get the
> actual heap usage with simple method.
> normally for a given jvm, the size of an object can be calculated
> statically.
> what you need is to read source code of jvm, :)
>
> anyway, you can simple estimate size of an object as the summation of
> its properties, plus some additional header fields.
> NOTE that reference only occupy a pointer size unit. This is quite
> different from c++.
>
> On Wed, Nov 25, 2009 at 5:20 PM, Abhijeet Kumar
> <[email protected]> wrote:
> >
> > how do i measure the JVM memory ???
> > can u specify a command or class to use??
> >
> > On Wed, Nov 25, 2009 at 8:12 AM, Chakravarthi Muppalla <
> [email protected]>
> > wrote:
> >>
> >> measure jvm memory usage before/after creating ur object; but it is not
> >> assured to give the correct size(gc).
> >> or u can use a premain agent.
> >>
> >> On Wed, Nov 25, 2009 at 12:37 AM, Abhijeet Kumar
> >> <[email protected]> wrote:
> >>>
> >>> How can i find size of an object in java????
> >>> plsss answer asap
> >>>
> >>> --
> >>>
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Algorithm Geeks" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to
> >>> [email protected]<algogeeks%[email protected]>
> .
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >>
> >>
> >> --
> >> Thanks,
> >> Chakravarthi.
> >>
> >> --
> >>
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected]<algogeeks%[email protected]>
> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >
> >
> >
> > --
> > Cheers..
> > Abhijeet Kumar
> >
> > --
> >
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<algogeeks%[email protected]>
> .
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
>


-- 
Thanks
Phani
http://www.phanikumar.com/

--

You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.


Reply via email to