Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication2;
- import java.util.Date;
- public class JavaApplication2 {
- public static void main(String[] args) {
- printMemory();
- Date[] myDates = new Date[50000];
- printMemory();
- /*
- for (int i = 0; i < myDates.length; i++) {
- myDates[i] = null;
- }
- */
- myDates = null;
- System.gc();
- printMemory();
- }
- static void printMemory() {
- System.out.println("Total & Free Memory:");
- System.out.println("Total Memory: " + Runtime.getRuntime().totalMemory());
- System.out.println("Free Memory: " + Runtime.getRuntime().freeMemory());
- System.out.println("--------------------");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment