If it’s a good idea to learn proper memory management skills, as Cameron Laird has suggested in his series, then you’ll need to gain skill at using the tools that help you do so. In this article, you’ll learn how to use a free memory debugging utility and find out how easily it can help you solve memory problems.
The best way to avoid memory errors is to not use C or C++ unless you have to, but when you have to, working without Valgrind is like flying blind.
Not sure I see much value in many of the GUI frontends to Valgrind so far, but there is a lot that could be done with IDE integration, etc.
Can anyone recommend a free (as in cost) Windows alternative to Valgrind? I know you can use Wine in Linux to debug Windows programs, but that’s not very practical.
Thanks.
Will anyone be kind enough to provide me with links to the first two preceding articles?
Just click on the name of the author and you will see all articles he has written for that site.
#1 http://www.informit.com/articles/article.asp?p=169586
#2 http://www.informit.com/articles/article.asp?p=169670
…then use MMGR (Midnight’s Memory Manager) which you can find amongst other free tools here: http://www.fluidstudios.com/publications.html
Works excellent under Windows and I’d assume under most Unix derivatives too.
It’s not valgrind, though. But incredibly useful.
And that’s a bunch of BS. Because memory handling in both languages is different. I don’t see one instance of RAII, boost::shared_pointer, std::auto_ptr, std::vector, or std::cout.
All I see are bald pointers, printf statements, and arrays on the stack.
C++’s greatest strength is its greatest weakness. Developers think they are using C++ but they are really using C.
There are Garbage Collection libs for c++. Some are free as in beer, some are free as in freedom, and some are commercial. For GUI, the best thing to use and contribute to is the Visual Component Framework (VCF) at vcf.sourceforge.net or buy Qt if you have the money.
Parveen, I agree with what you said.
He shouldn’t have lumped C with C++.
The last paragraph says:
“The first three articles of this series have mostly lumped together C and C++ in examining the advantages and limits of memory debuggers. The final installment will concentrate on aspects that are specific to C++: whether C++ is enough of an improvement on C to obviate the need for memory debuggers, what’s special about C++ memory use, and how to code in C++ to avoid memory errors.”
He should have said in the beginning that this article focused on C and not C++
from the article summary:
“find out how easily it can help you solve memory problems”
From seeing the examples in the article, first I would advise programming lessons. Then there should be less problems.