Map
Index
Random
Help
Topics
th

Topic: finalization of data

topics > computer science > data > Group: data value



Topic:
data type as constructors, selectors, and predicates
Topic:
initialization of data
Topic:
memory management by garbage collection

Summary

Data is finalized before it is destroyed. For example, finalization may be used to release allocated resources. In C++, a finalizer is called a destructor.

Finalization works well for locally scoped objects and explicit destructors. It helps prevent resource leaks for exception handling and other abnormal execution sequences.

For garbage-collected objects, programmers should not depend on finalization. Finalization may occur long after the data becomes inaccessible. It may never occur. An alternative is registering the object for cleanup. (cbb 7/06)

Subtopic: finalization up

Quote: an abstract data type needs a finalization operation that occurs on deallocation of an object; for updating related data structures [»schwRL3_1981]
QuoteRef: wulfWA4_1974 ;;7 every form has a create and destroy function for own and local instantiations
Quote: delete objects of a derived class with a virtual destructor in the base class; it will know the size of the object [»stroB_1991]
Quote: classes with nontrivial destructors need to define an assignment operator and copy constructor

Subtopic: exceptions up

Quote: if a fictitious block for each declaration then exceptions can finalize the object before reraising the exception [»schwRL3_1981]
Quote: exception-safety provides the basic-guarantee and may provide strong or no-throw guarantees; destructors do not throw exceptions [»abraD4_1998]

Subtopic: registration server up

Quote: use a registration server instead of garbage-collection; register an object for cleanup at program termination; remove registration if object is explicitly terminated

Subtopic: problems up

Quote: exceptions during finalization and initialization are difficult to handle properly
Quote: ill-defined finalization operations introduces serious complications to a language [»schwRL3_1981]
Quote: actions performed "at garbage-collection time" may occur any time between the object's last use and program termination; must execute under an unknown state [»stroB_1991]
Quote: Java finalizers execute in an arbitrary order or not at all; avoid or use explicit garbage collection
[»alexRT1_2000]

Related Topics up

Topic: data type as constructors, selectors, and predicates (20 items)
Topic: initialization of data (45 items)
Topic: memory management by garbage collection
(116 items)

Updated barberCB 6/04
Copyright © 2002-2008 by C. Bradford Barber. All rights reserved.
Thesa is a trademark of C. Bradford Barber.