magallanes magallanes - 1 year ago 93
Java Question

What is the memory size of an ArrayList in Java

I have an

and I wish to know how much memory it is using.

is variant so, it is not as easy as multiply the number of elements in the array per the size of an object.

Answer Source

You can use something like Runtime.getRuntime().totalMemory() and its counterpart Runtime.getRuntime().freeMemory() to get an educated guess, but that doesn't account for objects that are GC'ed between calls.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download