Small Memory Leak in DetectorHistogrammer
Summary
Running Valgrind reveals some memory leak in the DetectorHistogrammer and its way of handling the PixelHit pointer. Maybe it would be worthwile rewriting the Cluster
class a bit?
Relevant event logs
Output of valgrind --tool=memcheck --leak-check=yes ../bin/allpix -c ../conf/test_config.conf
==20961== 13,040 (4,400 direct, 8,640 indirect) bytes in 55 blocks are definitely lost in loss record 13,837 of 14,310
==20961== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20961== by 0x549C9B8: allpix::DetectorHistogrammerModule::doClustering() (DetectorHistogrammerModule.cpp:243)
==20961== by 0x549C1AD: allpix::DetectorHistogrammerModule::run(unsigned int) (DetectorHistogrammerModule.cpp:127)
==20961== by 0x7724B4E: allpix::ModuleManager::run()::$_1::operator()() const (ModuleManager.cpp:675)
==20961== by 0x772385F: allpix::ModuleManager::run() (ModuleManager.cpp:694)
==20961== by 0x775723F: allpix::Allpix::run() (Allpix.cpp:211)
==20961== by 0x4049AC: main (allpix.cpp:161)
==20961==
==20961== 17,720 (3,040 direct, 14,680 indirect) bytes in 76 blocks are definitely lost in loss record 13,961 of 14,310
==20961== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20961== by 0x549E9E6: allocate (new_allocator.h:111)
==20961== by 0x549E9E6: allocate (alloc_traits.h:436)
==20961== by 0x549E9E6: _M_get_node (stl_tree.h:588)
==20961== by 0x549E9E6: _M_create_node<const allpix::PixelHit *const &> (stl_tree.h:642)
==20961== by 0x549E9E6: operator()<const allpix::PixelHit *const &> (stl_tree.h:556)
==20961== by 0x549E9E6: _M_insert_<const allpix::PixelHit *const &, std::_Rb_tree<const allpix::PixelHit *, const allpix::PixelHit *, std::_Identity<const allpix::PixelHit *>, std::less<const allpix::PixelHit *>, std::allocator<const allpix::PixelHit *> >::_Alloc_node> (stl_tree.h:1753)
==20961== by 0x549E9E6: _M_insert_unique<const allpix::PixelHit *const &> (stl_tree.h:2096)
==20961== by 0x549E9E6: insert (stl_set.h:502)
==20961== by 0x549E9E6: allpix::Cluster::Cluster(allpix::PixelHit const*) (Cluster.cpp:20)
==20961== by 0x549C9C6: allpix::DetectorHistogrammerModule::doClustering() (DetectorHistogrammerModule.cpp:243)
==20961== by 0x549C1AD: allpix::DetectorHistogrammerModule::run(unsigned int) (DetectorHistogrammerModule.cpp:127)
==20961== by 0x7724B4E: allpix::ModuleManager::run()::$_1::operator()() const (ModuleManager.cpp:675)
==20961== by 0x772385F: allpix::ModuleManager::run() (ModuleManager.cpp:694)
==20961== by 0x775723F: allpix::Allpix::run() (Allpix.cpp:211)
==20961== by 0x4049AC: main (allpix.cpp:161)
==20961==
==20961== 17,800 (2,880 direct, 14,920 indirect) bytes in 72 blocks are definitely lost in loss record 13,962 of 14,310
==20961== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20961== by 0x549EB0C: allocate (new_allocator.h:111)
==20961== by 0x549EB0C: allocate (alloc_traits.h:436)
==20961== by 0x549EB0C: _M_get_node (stl_tree.h:588)
==20961== by 0x549EB0C: _M_create_node<const allpix::PixelHit *const &> (stl_tree.h:642)
==20961== by 0x549EB0C: operator()<const allpix::PixelHit *const &> (stl_tree.h:556)
==20961== by 0x549EB0C: _M_insert_<const allpix::PixelHit *const &, std::_Rb_tree<const allpix::PixelHit *, const allpix::PixelHit *, std::_Identity<const allpix::PixelHit *>, std::less<const allpix::PixelHit *>, std::allocator<const allpix::PixelHit *> >::_Alloc_node> (stl_tree.h:1753)
==20961== by 0x549EB0C: _M_insert_unique<const allpix::PixelHit *const &> (stl_tree.h:2096)
==20961== by 0x549EB0C: insert (stl_set.h:502)
==20961== by 0x549EB0C: allpix::Cluster::addPixelHit(allpix::PixelHit const*) (Cluster.cpp:30)
==20961== by 0x549D9EB: allpix::DetectorHistogrammerModule::checkAdjacentPixels(allpix::PixelHit const*) (DetectorHistogrammerModule.cpp:268)
==20961== by 0x549C82A: allpix::DetectorHistogrammerModule::doClustering() (DetectorHistogrammerModule.cpp:241)
==20961== by 0x549C1AD: allpix::DetectorHistogrammerModule::run(unsigned int) (DetectorHistogrammerModule.cpp:127)
==20961== by 0x7724B4E: allpix::ModuleManager::run()::$_1::operator()() const (ModuleManager.cpp:675)
==20961== by 0x772385F: allpix::ModuleManager::run() (ModuleManager.cpp:694)
==20961== by 0x775723F: allpix::Allpix::run() (Allpix.cpp:211)
==20961== by 0x4049AC: main (allpix.cpp:161)
==20961==