| www.delorie.com/gnu/docs/smalltalk/gst_17.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A few methods in Object support the creation of particular objects. This include:
finalize method is called. Before finalize is called,
the VM implicitly removes the objects from the list of finalizable
ones. If necessary, the finalize method can mark again
the object as finalizable, but by default finalization will only occur
once.
Note that a finalizable object is kept in memory even when it has no
references, because tricky finalizers might "resuscitate" the object;
automatic marking of the object as not to be finalized has the nice side
effect that the VM can simply delay the releasing of the memory associated
to the object, instead of being forced to waste memory even after
finalization happens.
An object must be explicitly marked as to be finalized every time the
image is loaded; that is, finalizability is not preserved by an
image save. This was done because in most cases finalization is
used together with CObjects that would be stale when the image is
loaded again, causing a segmentation violation as soon as they are accessed
by the finalization method.
become:, basicAt:put:,
and possibly at:put: too (depending on the implementation of the
method).
Note that GNU Smalltalk won't try to intercept assignments to fixed
instance variables, nor assignments via instVarAt:put:. Many
objects (Characters, nil, true, false, method
literals) are read-only by default.
aBoolean.
#basicNew, but the object won't move across garbage
collections.
#basicNew:, but the object won't move across garbage
collections.
#new
or #new: to create an object
Note that, although particular applications will indeed have a need for
fixed, read-only or finalizable objects, the #makeWeak primitive
is seldom needed and weak objects are normally used only indirectly,
through the so called weak collections. These are easier to use
because they provide additional functionality (for example, WeakArray
is able to determine whether an item has been garbage collected, and
WeakSet implements hash table functionality); they are:
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |