Answer Posted / ashwani maddeshiya
static void gc() // Requests GC to run
static void runFinalization() // Requests finalizers to run
OR
mport java.util.*;
class GarbageCollectionDemo
{
public static void main(String s[]) throws Exception
{
// Get runtime environment
Runtime rt = Runtime.getRuntime();
System.out.println("Free memory before Garbage Collection = "+rt.freeMemory());
// Apply garbage collection
rt.gc();
System.out.println("Free memory after Garbage Collection = "+rt.freeMemory());
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is method reference in java?
What is the purpose of declaring a variable as final?
Which is illegal identifier in java?
What two classes are used to read data only?
Can we create a class inside a class in java?
What is the super void?
Why Java doesn’t support multiple inheritance?
Differentiate between stringbuffer and string?
How do you get the length of a string in java?
What if static is removed from main method?
How to declare objects of a class ?
Can I overload to string method
How many types of array are there?
Is jdk required on each machine to run a java program?
Say any two properties in beans?