TDD and Memory Leaks
I made the C++ unit test harness I use check for memory leaks on a test by test basis. I was amazed at how easily a leak can sneak into a C++ program. I think TDD is a great way to stamp out leaks in C++ programs.
Now that I have my leak detector running I see that there are standard library routines (string, stringstream for example) that are not so diligent. It seems that in some implementations of the standard library allocate things then do not release them until the program terminates (or maybe never). I added a control to the unit tests so that they can be optionally run twice. This provides some evidence that the library routines don’t habitually leak.
!commentForm
Great idea James. I'd love to hear more details. Ideally I'd like to see the memory checks in the next release of the tool you use. (CppUnitLite[?]?) Any chance?
Hi Kelley
The leak detection is already part of CppTestTools[?], which contains an evolved version of CppUnitLite[?]. See Fitnesse.org's CppFit[?] page.
The leak detection is already part of CppTestTools[?], which contains an evolved version of CppUnitLite[?]. See Fitnesse.org's CppFit[?] page.
Add Child Page to TddAndMemoryLeaks