Garbage collection with -finalize?
Garbage collection with -finalize?
- Subject: Garbage collection with -finalize?
- From: Andrew Merenbach <email@hidden>
- Date: Wed, 30 Nov 2005 17:22:31 -0800
I've seen some discussions on garbage collection here before, but a
search of Google and a search of CocoaBuilder turned up nothing, and
a search of the Documentation yielded vague results. I apologise
very much if this is a silly question, then, but:
What is this -(void)finalize method in NSObject's docs (running Xcode
2.2 under Tiger 10.4.3, with the November documentation patch applied)?
Called by the garbage collector when the receiver is not referenced
by other objects.
Note: Garbage collection is not available for use in Mac OS X
v10.4, nor in earlier versions.
The garbage collector invokes this method on the receiver before
disposing of the memory it uses. When garbage collection is
enabled, this method is invoked instead of dealloc.
Override this method to relinquish resources the receiver has
obtained:
...
It is an error to store self into a new or existing live object
(colloquially known as “resurrection”), which implies that this
method will be called only once. However, the receiver may be
messaged after finalization by other objects also being finalized
at this time, so your override should guard against future use of
resources that have beeen reclaimed, as shown by the log_file =
NULL statement in the example.
Availability
Available in Mac OS X v10.4 and later.
See Also: – dealloc
A garbage collection method available in 10.4, when garbage
collection isn't available in 10.4? If this is new, why might I not
have found a great deal of speculation, from this addition, on
whether Mac OS 10.5 or 10.4.8 or something in the far future would
allow it?
Or... to speculate... as an assistant to those porting their Java
programs to Cocoa (note the recent thread on the deprecation of the
Cocoa-Java bridge after Tiger).
Curiously,
Andrew
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden