Good morning, I want to monitor how much memory my java process is using at any given time. Is there a way, within a java process, to determine how much memory is being used by that process? I could use Windows Task Manager, but we want to start several processes on several boxes and have each process monitor itself. Is this possible? The main item of interest is how much memory my current process is using. Thanks, Curtis
Well in one of jobs I worked in a project developing a system monitoring software. It had a scaled down free version including monitoring agents, a logging and a reporting server, it should be perfect for your needs. I am not sure if they are giving it for free anymore. You can contact them at http://www.path-communications.com Hope it helps.
tobe bondhu nouka bherao<br />shonabo gaan aj shara raat
Joined: Sep 12, 2001
Ok guys, I found my own answer... Using the following code, you can get the current memory being used by you java process: //initialize it once, it keeps up to date.. Runtime runtime = Runtime.getRuntime();
//then call this whenever you want to know the //current memory used by your process... System.out.println(runtime.totalMemory());
In case anyone was unclear ... totalMemory() returns the amount of memory used by the JVM. However, this is rather loosely related to the amount of memory that your Java program is actively using at any instant. That is because of garbage accumulation and collection. Your Java program might have a 64Mbyte heap, but only 1Mbyte of active objects, the rest of the heap being either free or used by dead objects. The totalMemory() method tells you about the heap size, not the amount of memory used by active objects. For the same reason, watching the size of your Java process in Windows Task Manager or UNIX top is not very helpful, as again this relates to the heap size, not how much is in use by active objects.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.