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 remarkable, but on the whole, perhaps, not to be lamented, that the world is so unkind to a new book. Any distinguished traveler who comes to our shores is likely to get more dinners and speeches of welcome than he can well dispose of, but the best books, if noticed at all, meet with coldness and suspicion, or, what is worse, gratuitous, off-hand criticism.”
—Henry David Thoreau (1817–1862)
“With only one life to live we can’t afford to live it only for itself. Somehow we must each for himself, find the way in which we can make our individual lives fit into the pattern of all the lives which surround it. We must establish our own relationships to the whole. And each must do it in his own way, using his own talents, relying on his own integrity and strength, climbing his own road to his own summit.”
—Hortense Odlum (1892–?)