PDA

View Full Version : Determine allocated memory from within the Java app


Kees de Kooter
31-07-2008, 15:19
I want to display some basic memory info (like the heap size in the eclipse status bar).

Which api should I use?

kjkoster
01-08-2008, 19:15
Dear Kees,

What will you use it for?

Most likely you will either end up using java.lang.Runtime if the code needs to be portable to Java 1.4 and older. If you use Java 1.5 and up use JMX. Here is an explanation of Java's memory pools (http://www.kjkoster.org/zapcat/Zabbix_Java_Template.html) and what to look for using JMX.

Kees Jan

Kees de Kooter
01-08-2008, 19:22
Thanks Kees Jan.

I want to put some "impressive numbers" on a sysinfo page, monitoring is not an immediate requirement. java.lang.Runtime will do for now.