gc() method

PHOTO EMBED

Thu Dec 21 2023 16:34:13 GMT+0000 (Coordinated Universal Time)

Saved by @user01

import java.util.*;
class GarbageCollector{
	public static void main(String[]args){
		System.gc();
		Runtime rt = Runtime.getRuntime();
		long total = rt.total();
		long free = rt.free();
		long max = rt.max();
		System.out.println("total"+total+"bytes");
		System.out.println("free"+free+"bytes");
		System.out.println("max"+max+"bytes");
		rt.gc();
		total = rt.total();
		free = rt.free();
		max = rt.max();
		System.out.println("total after gc"+total+"bytes");
		System.out.println("free after gc"+free+"bytes");
		System.out.println("max after gc"+max+"bytes");
	}
}	
		
		
content_copyCOPY