Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to send a request to garbage collector?

Answers were Sorted based on User's Feedback



How to send a request to garbage collector?..

Answer / anjum rehbar khan

Yes we can send arequest to garbage collection by writing a
simple line of code:

System.gc();

OR

Runtime.gc();

But it is simply a request not a order to JVM
because Garbage collection is JVM dependent

Is This Answer Correct ?    8 Yes 0 No

How to send a request to garbage collector?..

Answer / uv

As far as I know,it is not required to call the garbage
collector.
It automatically and periodically removes the unused
objects by an algorithm known as "Mark and Sweep".

However, if we intentionally want to call it then the above
suggestions are perfect.
Anyone who feels that it is incorrect, please feel free to
correct me.

Is This Answer Correct ?    4 Yes 0 No

How to send a request to garbage collector?..

Answer / chinna

It's Runtime.getRuntime().gc()

Is This Answer Correct ?    3 Yes 0 No

How to send a request to garbage collector?..

Answer / 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

More Core Java Interview Questions

How can be define MARKER interfce in java

1 Answers  


What is the applet security manager, and what does it provide?

0 Answers  


What are the two categories of data types in the java programming language?

0 Answers  


What is the difference between I ++ and ++ I in java?

0 Answers  


What is a locale?

0 Answers   Aspire, Infogain,


What is the function of compareto in java?

0 Answers  


why Runnable interface is preferable than extending the Thread class?

7 Answers   Aizza, College School Exams Tests, Sybrant Technologies, Wipro,


Can we print null in java?

0 Answers  


How do you know if a value is nan?

0 Answers  


In what ways you can handle exception ?

3 Answers  


Why do we need array in java?

0 Answers  


Is java call by reference?

0 Answers  


Categories