Content deleted Content added
→top: resource leak |
e.g. is enough |
||
Line 3:
In [[computer programming]], the '''dispose pattern''' is a [[design pattern (computer science)|design pattern]] which is used to handle resource cleanup and prevent [[resource leak]]s in [[runtime environment]]s 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 [[finalizer]]s rather than [[destructor (computer science)|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 (computer science)|method]] (usually called <code>Dispose</code> 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 (
== Motivation ==
|