In computer programming, the dispose pattern is a design pattern which is used to handle resource cleanup in runtime environments that use automatic garbage collection. The fundamental problem that the dispose pattern aims to solve is that, because objects in a garbage-collected environment have finalizers rather than destructors, there is no guarantee that an object will be destroyed at any deterministic point in time. The dispose pattern works around this by giving an object a method (usually called Dispose
or similar) which frees any resources the object is holding onto.
Many garbage-collected languages offer language constructs to avoid having to call the dispose method explicitly in many situations. These language constructs leads to results similar to what is obtained with the Resource Acquisition Is Initialization (RAII) idiom in languages with deterministic memory management (like e.g. C++).
Read more about Dispose Pattern: Motivation, Language Constructs
Famous quotes containing the words dispose and/or pattern:
“It is plain that the reviewers, both here and abroad, do not know how to dispose of this man.”
—Henry David Thoreau (18171862)
“For what is wedlock forcèd, but a hell,
An age of discord and continual strife?
Whereas the contrary bringeth bliss,
And is a pattern of celestial peace.”
—William Shakespeare (15641616)