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 the importance of main method in Java?
How do you execute a thread in java?
what is session in java?
Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx
From the two, which would be easier to write: synchronization code for ten threads or two threads?
What do you mean by flow of struts?
How do listeners work?
how does multithreading take place on a computer with a single cpu? : Java thread
What is polymorphism and what are the types of it?
design an lru cache in java?
What are the default and parameterized constructors?
What are the restriction imposed on a static method or a static block of code?
Which sorting algorithm is in place?
What are the main uses of this keyword?
How would you dynamically allocate memory to an array?