In this section, you will learn how to force a garbage collector to work by creating many objects.
Description of program:
The following code of program will help you in forcing the garbage collection. First of all we have created an object for the garbage collector to perform some operation. Then we have used the System.gc(); method to force the garbage collection on that object. Then we have used the System.currentTimeMillis(); method to show the time take by the garbage collector.
Output of the program:
Garbage Collection started explicitly.
It took 782 ms
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: March 20, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles