Garbage Collector

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Garbage Collector

How does garbage collector decide which objects are to be removed? Can garbage collector be forced? Garbage collector is invoked by JVM automatically. This function checks for all the object in heap memory and whether oject are having any refrence or not. If an object does have any refrence variable means it is unreachable then garbage collector frees that memory. By using system.gc() commond we can run garbage collector forcefully. Garbage collector removes those objects from heap memory which are no longer referred by any other objects. Using System.gc() you can call garbage collector but its not neccesary that it will run. JVM decides when the Garbage Collector will run.

How does garbage collection work


Latest Answer : When Java was originally developed, the JDK shipped with a mark-and-sweep garbage collector. A mark-and-sweep garbage collector proceeds in two phases: Mark: identifies garbage objects Sweep: reclaims the memory for the garbage objectsGarbage objects ...

How does garbage collection work


Latest Answer : When Java was originally developed, the JDK shipped with a mark-and-sweep garbage collector. A mark-and-sweep garbage collector proceeds in two phases: Mark: identifies garbage objects Sweep: reclaims the memory for the garbage objectsGarbage objects ... Read Answers (8) Answer Question Subscribe

What are the disadvantages of reference counting in garbage collection


Latest Answer : An advantage of this scheme is that it can run in small chunks of time closely interwoven with the execution of the program. This characteristic makes it particularly suitable for real-time environments where the program can't be interrupted for very ... Read Answers (1) Answer Question Subscribe

1)whether we can set the time implicitly for the garbage collection?
Latest Answer : No you cannot start garbage collection by your own.By executing System.gc() you just b sure that GC will b run, but when cannot be told. ... Read Answers (3) | Asked by : chandu Answer Question Subscribe

Whether a Class,Method can be garbage collected or not?How?


Latest Answer : Class and Method are not garbage collected because class and methods are the predefined instruction formats for developing an object oriented programming. ... Read Answers (7) | Asked by : chandu Answer Question Subscribe

Explain Garbage collection mechanism in Java


Latest Answer : Like in c and c++ we have some mechanism to create the object and some mechnaishm to distroy the object .but in java we have mechanism to create the object but we dont have any mechanism to distroy the object ..so some data can be unused that ... Read Answers (4) | Asked by : Beena

Answer Question

Subscribe

Why there is no guarentee for System.gc() method will perform garbage collection for a particular time?
Why there is no guarentee for System.gc() method will perform garbage collection for a particular time? Read Answers (2) | Asked by : chandu Answer Question Subscribe

What is garbage collection? can it be forced?


Latest Answer : Garbage Collection: If no longer any obejct need to any variable, java automatically reclaimes the memory.U can't force the GC, U have to give the request by using system.gc() and even not guarante that its immediatly to reclaims the memory........... ... Read Answers (11) | Asked by : kanchan Answer Question Subscribe

Why was Java Created?


PlatForm Indepentdent ,security,Garbage Collection. Latest Answer : Java is created for simple OOP.It doesnt use multiple inheritance for simplicity hence it is not pure OOP.Java uses JVM, hence it is platform independent.Java uses collections hence it is easy to code.It has a huge API, so LOC are reduced.Java doesn't ...

You might also like