Chris Sommers writes:
 > Estmeemed wizards,
 > How can I estimate how much memory an object or bunch of
 > objects consume - besides indirectly, e.g. looking at
 > Runtime.getRuntime().totalMemory()? For example, how big is
 > a Vector containing 10,000 of class Double? I'm sure it will
 > be JVM/platform-dependent, but there must be a way to
 > estimate it.
 > 
 > Is there documentation on this topic? It seems fundamental.

It's very VM dependent, and given that memory is dynamically allocated, you're
not supposed to have to worry about it.

In objects, each data member consumes 4 bytes, except for doubles, which take
8.  Additionally, there's some per-instance overhead, say a class pointer, an
object table pointer, and maybe a size indicator, so figure another 12 bytes
overhead per instance (although 16 bytes per comes to mind from some previous
analysis that I did).   For a double[10], figure 8*10 + the overhead for the
arrya, so probably about 92-96 bytes.  

Steve

Reply via email to