Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > MONITOR MEMORY IN JAVA

Reply
Thread Tools

MONITOR MEMORY IN JAVA

 
 
memy memy is offline
Junior Member
Join Date: Oct 2010
Posts: 1
 
      10-31-2010
HI

pleas help me i want aprogram

to monitor memory in java

to get information

please help meeeeeeee
 
Reply With Quote
 
 
 
 
fe.aa fe.aa is offline
Junior Member
Join Date: Nov 2010
Posts: 1
 
      11-02-2010
Hope this helps, i came across it a few weeks ago, so i thought i google it and help you out:

public class MemoryTest {


public static void main(String [] args) {

int mb = 1024*1024;

//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();

System.out.println("##### Heap utilization statistics [MB] #####");

//Print used memory
System.out.println("Used Memory:"
+ (runtime.totalMemory() - runtime.freeMemory()) / mb);

//Print free memory
System.out.println("Free Memory:"
+ runtime.freeMemory() / mb);

//Print total available memory
System.out.println("Total Memory:" + runtime.totalMemory() / mb);

//Print Maximum available memory
System.out.println("Max Memory:" + runtime.maxMemory() / mb);
}
}

Cheers!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ping monitor - monitor ip in the background? ScottZ Python 2 11-02-2008 09:04 AM
computer dead but fan n monitor(blank)only light beeps on monitor works!! ikshahang General Computer Support 1 08-26-2007 12:52 PM
Large flat panel tv monitor as PC monitor Ed Computer Support 6 10-23-2006 07:31 AM
Monitor settings for Pack.Bell, can't find the right monitor anyway fredcromer Computer Information 1 05-06-2004 04:29 PM
KDS monitor producing bright white line at top of monitor screen Bun Mui Computer Support 0 11-30-2003 07:48 PM



Advertisments