0
What is the exact process of garbage collection in JAVA. Its so confusing in the notes.
Garbage collection in JAVA
4 Antworten
+ 6
Just a memory manager.
Everything in Java is object. So, whenever an object is destroyed, the memory it consumed should be unallocated to be used by some other objects.
This task is done by Garbage Collector.
You might be confused with the name, why it is called garbage?
It is because when an object gets free, the memory it consumed become useless and since the object doesn't exist, their is no possibility to access the memory location, so the memory space become a place which contains garbage.
+ 4
When an object becomes an 'Orphan' the garbage collector 'picks it up' to free up memory. New objects can then use this memory.
It is essentially automatic memory management.
+ 3
@Manish
By orphan I basically mean unreachable, or no reference.
Here's an example from a post from stackOverFlow:
"Integer i = new Integer(4); // the new Integer object is reachable via the reference in 'i'
i = null; // the Integer object is no longer reachable"
So the Integer object will be ready when the garbage collector is.
0
Can you please explain what exactly is an 'Orphan' object?