Java garbage collectionPritesh
Garbage Collection : Destroying Object in Java Programming
- Object is Created Using new Operator.
- Object gets memory inside “Heap“.
- In C++ After Using Object , Memory for Object gets de-allocated using delete().
- In Java De-allocation of Object Can be done automatically.
- Automatic Technique used in Java Programming Which is used to de-allocate memory is called as “Garbage Collection“.
- Java is Smart Enough to identify the Unused objects or Useless Objects.
- Garbage Collection is Done Automatically by JVM.
- As soon as compiler detects that – Object is no longer needed inside program , Garbage Collection Algorithm gets executed automatically to free up memory from the heap so that free memory may be used by other objects .
- Different Java Run times may have different approaches for Garbage Collection. [This is required information to understand Garbage Collection – Doing Further R&D you may visit this]