Easy learning with example program codes

Java Runtime freeMemory() and totalMemory() method

public class Test {
  public static void main(String[] args) {
	  Runtime runtime=Runtime.getRuntime();  
	  System.out.println("Total Memory: "+runtime.totalMemory());  
	  System.out.println("Free Memory: "+runtime.freeMemory());  
	  for(int i=0;i<15000;i++){  
	   new Test();  
	  System.out.println("Free Memory, after creating 15000 instance: "+runtime.freeMemory());  
	  System.out.println("Free Memory after gc(): "+runtime.freeMemory());  
Please follow and like us:
Posted in Java   

Copyright © 2019 CodesJava Protection Status