On Tue, 28 Aug 2001 21:07:03 -0400 (EDT), Sam Tregar <[EMAIL PROTECTED]>
wrote:
>On Wed, 29 Aug 2001, Jeremy Howard wrote:
>
>> 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.
>
>Well, there's the Perl 5 reference counting solution. In normal cases
>DESTROY is called as soon as it can be. Of course we're all anxious to
>get into the leaky GC boat with Java and C# because we've heard it's
>faster. I wonder how fast it is when it's halfway under water and out of
>file descriptors.
With GC, it is of course again the duty of the programmer to make sure the
resources are freed on time:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpapndx/html/_cor_finalize_and_dispose.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguidnf/html/cpconcleaningupunmanagedresources.asp
C# has some syntactic sugar to make this a little more convenient to use:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_8_13.asp
Having to do explicit resource management is a real pain when you are used
to Perl 5's reference counting. :)
BTW, the lure of GC over refcounting is *not* the speed (it is only
slightly faster). The advantage is that it takes care of circular
references. And it can remove sandbars in your heap for long running
processes. It is also supposed to make your programs more robust because
you don't have to bother with keeping your reference counts rights. But
it has a ton of its own problems with resource management, so I'm not
convinced there.
-Jan