Wednesday, May 24, 2006

Size of a serialized java object using core java

I don't know of any easy way to find out how much memory an object in memory uses in Java. It is not in the standard API. If you really want to know, there might be a way using the debugger APIs, but it won't be easy. Note that the amount of memory an object occupies is implementation dependent - it might be different on different JVMs and on different platforms.

To find out the size of a serialized object: you could write the object to a file and see how large the file is. But the size of an object in serialized form is something different from the size an object occupies while it is "live" in memory.

0 Comments:

Post a Comment

<< Home