tags:

views:

157

answers:

2

Hello,

I'd like to be able to get the size of the heap as a variable. I don't need to change the size, just know what it is and have it in a variable.

Thanks!

+7  A: 

I haven't tried this before so I can't guarantee this will work, but try Runtime.totalMemory().

jboxer
This works, looks like it shows the size in bytes.
adam_0
+4  A: 

You can get application run time information

 Runtime rt = Runtime.getRuntime();

   rt.freeMemory();
   rt.totalMemory();
Thillakan