title: CppUnit leakage
body: <p>running my regression tests with valgrind I have this kind of report:</p>
  
  <pre>
  ==20341== 256 bytes in 1 blocks are indirectly lost in loss record 915 of 919                                                                                                         
  ==20341==    at 0x4A0661C: operator new(unsigned long) (vg_replace_malloc.c:220)                                                                                                      
  ==20341==    by 0x7F366FA: std::vector&lt;CppUnit::Test*, std::allocator&lt;CppUnit::Test*> >::_M_insert_aux(__gnu_cxx::__normal_iterator&lt;CppUnit::Test**, std::vector&lt;CppUnit::Test*, std::allocator&lt;CppUnit::Test*> > >, CppUnit::Test* const&) (new_allocator.h:88)                                                                                                            
  ==20341==    by 0x7F36496: CppUnit::TestSuite::addTest(CppUnit::Test*) (stl_vector.h:610)                                                                                             
  ==20341==    by 0x585B80: TestVectorAlgebra::addTestsToSuite(CppUnit::TestSuiteBuilderContextBase&) (testvectoralgebra.h:30)                                                          
  ==20341==    by 0x586719: TestVectorAlgebra::suite() (testvectoralgebra.h:42)                                                                                                         
  ==20341==    by 0x5948C4: CppUnit::TestSuiteFactory&lt;TestVectorAlgebra>::makeTest() (TestSuiteFactory.h:20)                                                                            
  ==20341==    by 0x7F2C6B0: CppUnit::TestFactoryRegistry::addTestToSuite(CppUnit::TestSuite*) (TestFactoryRegistry.cpp:149)                                                            
  ==20341==    by 0x7F2CAD5: CppUnit::TestFactoryRegistry::makeTest() (TestFactoryRegistry.cpp:136)                                                                                     
  ==20341==    by 0x580760: main (testunit.cpp:88)
  </pre>
  
  <p>I guess this is due the fact that Tests added to Suite are not removed before the main is over.</p>
  
  <p>This is the way I register the test:</p>
  
  <pre><code>  CppUnit::TextTestRunner::TestRunner runner;
  
    // Get the top level suite from the registry
    CppUnit::Test* myTest = 
      CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
  
    runner.addTest( myTest-&gt;findTest("TestVectorAlgebra") );
  </code></pre>
  
  <p>How do I unregister those tests ?</p>