Front page | perl.perl6.language |
Postings from August 2001
Re: finalization
Thread Previous
|
Thread Next
From:
Jeremy Howard
Date:
August 28, 2001 17:38
Subject:
Re: finalization
Message ID:
004a01c13022$e14aedd0$0ad7828b@samuel
Hong Zhang wrote:
> Most of finalization is used to deal with external resource, such as open
> file, socket, window. You don't really want to depend on finalization,
> since it is very likely run out of default file descriptor limit before
> the finalization kicks in. The rule of thumb is to let finalization to
> cleanup resource when an unexpected exception happens. It is more like
> a safe-net or parachute. It is most likely to help you in emergency, but
> there is no guarantee it will work.
>
There's a really interesting paper by one of the .NET development team
explaining why finalization and GC just don't go together:
http://www.mvps.org/vbnet/dev/vb7/vbdotnet_ms_resmanagement.htm
The answer used in .NET is to have a dispose() method (which is not a
special name--just an informal standard) that the class user calls manually
to clean up resources. It's not an ideal solution but there doesn't seem to
be many other practical options.
Thread Previous
|
Thread Next