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.
Image may be NSFW.
Clik here to view.
Explanation :
- 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]
The post Garbage Collection : Destroying Object in Java Programming appeared first on Learn Java Programming.