package com.demo.memoryheap;
import java.lang.management.ManagementFactory;
/**
* @author abdul
*
*/
public class FreeMemoryUsingMxBean {
/**
* @param args
*/
public static void main(String[] args) {
com.sun.management.OperatingSystemMXBean mxbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
System.out.println("Total Memory in MB: " + mxbean.getTotalPhysicalMemorySize()/(1024*1024));
System.out.println("Free Memory in MB: " + mxbean.getFreePhysicalMemorySize()/(1024*1024));
}
}
Note : If you get access restriction error while working on Eclipse , check this :
Access Restriction issue
import java.lang.management.ManagementFactory;
/**
* @author abdul
*
*/
public class FreeMemoryUsingMxBean {
/**
* @param args
*/
public static void main(String[] args) {
com.sun.management.OperatingSystemMXBean mxbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
System.out.println("Total Memory in MB: " + mxbean.getTotalPhysicalMemorySize()/(1024*1024));
System.out.println("Free Memory in MB: " + mxbean.getFreePhysicalMemorySize()/(1024*1024));
}
}
Note : If you get access restriction error while working on Eclipse , check this :
Access Restriction issue
Great ARticle
ReplyDeleteJava Online Course | Java Training in Chennai | Java Training Institutes in Chennai
Great Article android based projects
DeleteJava Training in Chennai
Project Center in Chennai
Java Training in Chennai
projects for cse
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
My Arcus offer java training with 100% placement. Our java training course that includes fundamentals and advance java training program with high priority jobs. java j2ee training with placement having more exposure in most of the industry nowadays in depth manner of java
ReplyDeletejava training in chennai