Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out Java's heap size on my computer?

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!

like image 642
adam_0 Avatar asked Dec 13 '22 01:12

adam_0


2 Answers

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

like image 172
jakeboxer Avatar answered Dec 24 '22 07:12

jakeboxer


You can get application run time information

 Runtime rt = Runtime.getRuntime();

   rt.freeMemory();
   rt.totalMemory();
like image 42
nayakam Avatar answered Dec 24 '22 06:12

nayakam