出典:Wikipedia
出典:『Wikipedia』 (2010/09/30 13:04 UTC 版)
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—a guarantee that is necessary for some other resource management patterns, such as Resource Acquisition Is Initialization. The dispose pattern works around this by giving an object a method (usually called Dispose() or something similar) which frees any resources the object is holding onto. Unless the language offers an alternative, this method must be manually invoked by clients that use the object once they are finished with it.