[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting size of a class
One technique that I've seen, since there is no direct method is to
serialize
the object and then check the size of the resultant array, String etc.
I've heard
this is not inexpensive.
If you do this only for development metrics you might not care about
expense.
A simple way since these will be your classes, is to implement
Externalizable and
then to put you more efficient writeExternal() method that will just
count the bytes
vs really go through the effort of writting to the outputStream.
Good luck, curt
Christopher Fowler wrote:
>I'm starting a big java project and I want to be very memory usage
>aware. I found a way to get the size of the heap. Is there a way I
>can get the size of a class? Normally in C I can use sizeof() on
>structures. Is there something similar?
>
>Thanks,
>Chris
>
>
>
--
Curt Smith
chsmith@speakeasy.net
(h) 404-294-6686
(w) 404-463-0973