1 / 7

Island of Isolation in Java with Example

https://firstcode.school/island-of-isolation-in-java/

Sudhanshi
Download Presentation

Island of Isolation in Java with Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Island of Isolation in Java with Example F I R S T C O D E . S C H O O L

  2. Island of isolation in Java: The Garbage Collector module does the destruction of objects. The objects that do not have any sort of references to them are eligible for garbage gathering. We use a Java garbage collector to identify such objects. In a situation when Object 1 references Object 2 and Object 2 references Object 1, but neither Object 1 nor Object 2 is referenced by another object, this is an island of confinement. Now, collecting all the items that reference each other but are not referenced by another dynamic object in the application is termed an island of isolation.

  3. Program explanation Before object destruction, the garbage collector invoke the finalize methods for one last time on the instance. In the given example, we call the finalize method twice as the count of objects qualifiable for garbage collection is two. This is due to absence of external forces to t1 and t2 after executing t2 = null. Only internal references to these values are present. In addition to it, we can call no other objects as there is no likelihood to call an instance variable of both the objects.

  4. Till t2.i = t1: Both the objects have external references t1 and t2.

  5. t1 = null: Both the objects can be reached via t2.i and t2 respectively.

  6. Here, both the objects are eligible for garbage collection as there is no way to call them. This is the Island of isolation.

  7. Conclusion N O W , Y O U M I G H T B E C L E A R A B O U T T H E I S L A N D O F I S O L A T I O N I N J A V A A N D G A R B A G E C O L L E C T I O N . Y O U A L S O G O T T O L E A R N H O W T O M A K E A N O B J E C T C O L L E C T I O N . T R Y T H E S A M P L E P R O G R A M T O F I N D T H E W O R K I N G O F T H I S C O N C E P T . H O W T O U S E I T I N T H E E L I G I B L E F O R G A R B A G E F I R S T C O D E . S C H O O L

More Related