科技报告详细信息
Destructors, Finalizers, and Synchronization
Boehm, Hans-J.
HP Development Company
关键词: destructors;    finalizers;    threads;    garbage collection;   
RP-ID  :  HPL-2002-335
学科分类:计算机科学(综合)
美国|英语
来源: HP Labs
PDF
【 摘 要 】

We compare two different facilities for running cleanup actions for objects that are about to reach the end of their life. Destructors, such as we find in C++, are invoked synchronously when an object goes out of scope. They make it easier to implement cleanup actions for objects of well-known lifetime, especially in the presence of exceptions. Languages like Java, Modula-3, and C# provide a different kind of "finalization" facility: Cleanup methods may be run when the garbage collector discovers a heap object to be otherwise inaccessible. Unlike C++ destructors, such methods run in a separate thread at some much less well-defined time. We argue that these are fundamentally different, and potentially complementary, language facilities. We also try to resolve some common misunderstandings about finalization in the process. In particular: 1. The asynchronous nature of finalizers is not just an accident of implementation or a shortcoming of tracing collectors; it is necessary for correctness of client code, fundamentally affects how finalizers must be written, and how finalization facilities should be presented to the user. 2. An object may legitimately be finalized while one of its methods are still running. This should and can be addressed by the language specification and client code. Notes: Copyright ACM To be presented at SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 15- 17 January 2003, New Orleans, LA

【 预 览 】
附件列表
Files Size Format View
RO201804100000082LZ 210KB PDF download
  文献评价指标  
  下载次数:5次 浏览次数:32次