Garo Garabedyan- a private blog

Everything here is written and belongs to me except otherwise noted.

Posts Tagged ‘Java

Garbage Collection in Java and Design Patterns

with 2 comments

Managing object deletion in Java is made automatically by Garbage Collector. Having this in mind it is crucial to know how to implement some patterns (like the Observer) which has a communication line (realized with storing refs) between objects.

Instead of the default object reference I offer you to use java.lang.ref.*

It is important to use not default object references in order instruct Garbage Collector to delete the object when up to him are only weak object references (which refs are supposed to keep the object in some pattern but not to keep it away of Garbage Collector).

Written by garabedyan

January 8, 2008 at 22:05