When we have Garbage collection in Java which basically empties space of all unused objects, why there are memory leaks in Java?
Printable View
When we have Garbage collection in Java which basically empties space of all unused objects, why there are memory leaks in Java?
The garbage collector removes objects which no longer have references to them (this is different in my mind than an 'unused object'). Keep a reference to an object, either accidentally or intentionally, and that object won't be Garbage collected.