Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Get Usage Memory Example 
 

In this Tutorial we make you a code that helps you in understanding Get Usage Memory.

 

Get Usage Memory Example

                         

In this Tutorial we make you a code that helps you in understanding Get Usage Memory. The class Memory Usage include the main method, that contain the following method - 

!)Runtime.getRuntime( ).total Memory ( )  -  This method return you the total amount of memory that your java program allocate inside JVM.

2)Runtime.getRuntime( ).free Memory ( )  -  This method return you the total amount of free memory available that your program allocate

The variable usage memory is calculated by subtracting total memory and free memory. Finally the println print the Total, Free and Usage memory.

MemoryUsage.java
public class MemoryUsage {

    public static void main(String args[]) {

        long totalMemory = Runtime.getRuntime().totalMemory();
        long freeMemory = Runtime.getRuntime().freeMemory();
        
        long usageMemory = totalMemory - freeMemory;
        
        System.out.println("Total Memory : " + totalMemory);
        System.out.println("Free Memory  : " + freeMemory);
        System.out.println("Usage Memory : " + usageMemory);
    }
}

Output :
Total Memory : 5177344
Free Memory  : 4978792
Usage Memory : 198552

Download code

                         

» View all related tutorials
Related Tags: java javascript c string oop array ant function script object diff fun io include help load variable sed print loop

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

Very nice...
thanks and pleasure for that...
Merry Christmas
11:58AM - 13 December 2008.

Posted by DAMN on Saturday, 12.13.08 @ 13:58pm | #82724

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.