|
![](/i/fill.gif) |
Darren New <dne### [at] san rr com> wrote:
> Right. In a GCed operating system, why would you own anything other than
> GCed resources?
I think you are talking about system resources. A program may use other
resources than simply system resources. If objects are never finalized,
how exactly are you going to free those resources? Manually?
Even then, sometimes even *memory* handling could require finalizers.
The quintessential example would be if you wanted to implement a
copy-on-write mechanism. In this case you need to "retain" and "release"
a reference counter each time an object takes hold of or drops a shared
block of memory. Without finalizers it becomes difficult.
You could have manual "retains" and "release" calls, but then we are
back to square one, ie. manual memory management, which is laborious and
error-prone, and hard to make exception-safe.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |