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:
“I find it so difficult to dispose of the few facts which to me are significant, that I hesitate to burden my attention with those which are insignificant, which only a divine mind could illustrate. Such is, for the most part, the news in newspapers and conversation.”
—Henry David Thoreau (18171862)
“It is a very true and expressive phrase, He looked daggers at me, for the first pattern and prototype of all daggers must have been a glance of the eye.... It is wonderful how we get about the streets without being wounded by these delicate and glancing weapons, a man can so nimbly whip out his rapier, or without being noticed carry it unsheathed. Yet it is rare that one gets seriously looked at.”
—Henry David Thoreau (18171862)