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 a class component?
What are the uses of synchronized keyword?
What is Java Shutdown Hook?
Which sort is best in java?
How does hashmap work in java ?
What is the preferred size of a component in java programming?
What is numeric data type?
What are the disadvantages of object oriented programming?
What is the collections api?
What are the basic control structures?
What are the main uses of this keyword?
Explain the use of javap tool.
Is there any sort function in java?
What is array list in java?
Can we define package statement after import statement in java?