Re: Garbage Collection - The Trash Begins To Pile Up
Thant Tessman wrote:
Allocating memory in an object constructor and deleting it in the
destructor *is* dynamic, explicit memory management from the
point-of-view of whoever wrote the class. And one would think that this
is the relevant perspective when discussing the general task of
programming in C++.
I am guessing I am not the only one who detects a bit of squirming
here. There was nothing unclear about what we wrote. We very clearly
stated that some people write this:
foo ()
{
Scanner *pScanner = new Scanner;
delete pScanner;
}
when they could have just as easily written this:
foo ()
{
Scanner scanner;
}
We argued that the latter style is generally preferable to the first.
So we are saying that you should not use new/delete inside of say,
global functions, for no compelling reason. What you wrote complete
ignores the point we were making.
And scope-activated memory management is a small and boring part of the
problem. The real action is all the crap that gets passed between
classes and all the non-hierarchical relationships between things and
the weird non-POD things you might need to put into your
"implicitly-managed" std::vector and all the situations where
'ownership' is not at all clear.
First all all, you do not put this "crap" in your implicitly managed
classes. You put ***pointers*** to this crap in your implicitly
managed classes. There is a significant difference, and the lack of
acknowledgement and respect for difference is, IMO, one of the
fundamental reasons why heapaphiliacs are more prone to make crap
(encapsulators of pointers to polymorphic objects notwithstanding).
Programmers outside the C++ and Java communities don't confuse the task
of memory management with the task of resource management. They are
different problems, and memory management at least is basically a solved
problem. And RAII is not the solution.
I am going to take what you just wrote and juxtapose it with a quote
from the link I provided in the OP so that you can see for yourself the
contradiction in your own statement:
You say:
"and memory management at least is basically a solved problem."
Microsoft says:
"Uncovering and correcting memory issues in managed applications can be
difficult. "
Note that these are "managed" applications, not "unmanaged"
applications. One would think that management adds value.
And let us not forget. dA/dt is currently > 0, where A is the number
of articles that are meant to rescue programmers from the illusion of
thinking they do not have to worry about memory management. Let us
see, together, just how many articles arise in the next 6 months about
all the tools and tips and tricks and pitfalls of
"managed",
"automatic",
"garbage collection"
Here is the link again from Microsoft:
http://msdn.microsoft.com/msdnmag/issues/06/08/nettingc/default.aspx
-Le Chaud Lapin-
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]