Re: In need of .NET advocacy

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Alex <response@xxxxxxxxxxxxx> wrote:
> The reason that I mentioned it in the first place is that I think
> that GC is not the main reson to switch to .NET and in our case,
> since some of our developers have been bitten by blindly relying on
> the Java GC, it is not even a "good" reason.

It's a very good reason - so long as you know what you're doing. Like
almost any other technology, you need to know what it's capable of and
what it's not capable of. It's wonderful when it comes to memory, but
awful for unmanaged resources - so don't use it for unmanaged
resources.

The "using" statement makes disposing of unmanaged resources in C# very
easy for the most part (when you don't need to embed them in objects
themselves) and the disposable pattern makes it easy to extend to the
rarer cases.

You've cited cases where Java developers have assumed that the GC can
cope with non-memory resources in a timely fashion - my counter-example
is that there are plenty of C++ programs which leak memory and wouldn't
if they used GCs. (Yes, there are GCs available for C++, but again you
end up with a particular "dialect" of C++ rather than "plain" C++.) The
GC should only be used to deal with memory, but I find that memory is
the resource I use most often.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: Disposing managed resources
    ... can, if it needs, to get more resources. ... using the Dispose() method of that interface. ... understand the .NET memory model very well, nor does he really seem to ... Almost all System.Drawing hold unmanaged resources ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Disposing managed resources
    ... The only case where disposing managed resources *may* be useful is "acquire ... it may help GC to dispose it and release references early so that GC ... > understand the .NET memory model very well, nor does he really seem to ... Almost all System.Drawing hold unmanaged resources and thus must be disposed as soon as possible. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Disposing managed resources
    ... The only case where disposing managed resources *may* be useful is "acquire ... or itself has unmanaged resources and thus implements ... understand the .NET memory model very well, nor does he really seem to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: REGION=0M and LSQA
    ... At the time, memory was very expensive, and we ... remaining storage and always issued a return code zero. ... programs actually worked in production, ... all of the resources used by the job up until that point ...
    (bit.listserv.ibm-main)
  • Re: A realistic price comparison
    ... > Spreading Apple FUD is just as bad as spreading Microsoft FUD. ... > However, I assure you, I had more than enough resources on my XP ... > instilled in them by having limited memory and disk space early on. ...
    (comp.sys.mac.advocacy)