If you are coming from a VB background you may not see it this way and I
What is that what you understand, I am curious what you mean with the
sentence above?
VB had a more deterministic way of cleaning up resources. I believe it has
reference counting. I'm not saying its better or worse, reference counting
has its problems too. I'm saying when all references to an object went away,
the object was cleaned up. I believe this is what Lloyd was complaining
about. Garbage collection on the other hand, the object is cleaned up when
the garbage collector gets around to it.
In my opinion it looks if you are making the often made fault from people
making programs, who have a small scoop on the different OS that are/have
been and programming languages.
They think often that solutions for failures in one programming language or
OS are universal solutions for all failures.
They think often that solutions for failures in one programming language or
OS are universal solutions for all failures.
I have built real-time and enterprise solutions in Unix/Windows/Linux with
C,C++,Perl,Java,VB and now C#/VB.NET.
And therefore my question again, why do you want to manage the managing code
by hand, what is the advantage?
Where do I say I want do that? I don't say that and I don't want to do that.
Just because the garbage collector takes care of most of the memory
problems, it does not take care of ALL the problems. Look around the message
boards, people complain about memory consumption all the time, its one of
the main complaints. There have been gazillion articles on understanding the
CLR, garbage collection, and memory consumption, along with best programming
practices. Many by MS insiders and experts. Memory consumption is an issue,
there things you should and should not do.
Example, when you get a .NET graphics object, it is a managed object, but
what should be the first thing you do with it when you are done with it. You
should call Dispose to release the underlying OS resources, in no way should
you let the garbage collector control the destruction of these resources,
this documented and suggested by MS themselves. Why? Because a managed
object could have a single handle property that points to a gigabyte sized
OS resource. What does the garbage collector see as the size of the object?
Ignoring the CLR overhead for the object itself, it thinks the size of the
object is 32 bits (or 64 if running on the 64 bit system). Will the garbage
collector be in a hurry to destroy this object? No, but in the meantime 1
gig of your memory is consumed by this dead object. Graphics object is not
the only "managed" object that has handles to OS resources.