vakho

20.04.13 - Java - N2

Apr 20th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package javaapplication2;
  2.  
  3. import java.util.Date;
  4.  
  5. public class JavaApplication2 {
  6.  
  7.    
  8.     public static void main(String[] args) {
  9.        
  10.         printMemory();
  11.        
  12.         Date[] myDates = new Date[50000];
  13.         printMemory();
  14.        
  15.         /*
  16.         for (int i = 0; i < myDates.length; i++) {
  17.             myDates[i] = null;
  18.         }
  19.         */
  20.        
  21.         myDates = null;
  22.        
  23.         System.gc();
  24.         printMemory();
  25.        
  26.     }
  27.    
  28.     static void printMemory() {
  29.         System.out.println("Total & Free Memory:");
  30.         System.out.println("Total Memory: " + Runtime.getRuntime().totalMemory());
  31.         System.out.println("Free  Memory: " + Runtime.getRuntime().freeMemory());
  32.         System.out.println("--------------------");
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment