Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vGate9.3 maybe with memory leak #615

Closed
Fantasticlyy opened this issue Jun 1, 2023 · 5 comments
Closed

vGate9.3 maybe with memory leak #615

Fantasticlyy opened this issue Jun 1, 2023 · 5 comments

Comments

@Fantasticlyy
Copy link

Describe the bug
use the vGate 9.3,while use digitizer and enable the “/gate/output/” ,when run a simulation ,the RAM will be raise by follow time,I thin may be enable the “/gate/output/” with memory leak,this issue only appear in vGate9.3 ,the other version not appear.
Desktop (please complete the following information):
vGate9.3 VirtualBox 7.06

#############

DIGITIZER

#############
/gate/digitizerMgr/name LESingles
/gate/digitizerMgr/chooseSD pixel
/gate/digitizerMgr/insert SinglesDigitizer
/gate/digitizerMgr/pixel/SinglesDigitizer/LESingles/setInputCollection Singles
/gate/digitizerMgr/pixel/SinglesDigitizer/LESingles/insert energyFraming
/gate/digitizerMgr/pixel/SinglesDigitizer/LESingles/energyFraming/setMin 0. keV
/gate/digitizerMgr/pixel/SinglesDigitizer/LESingles/energyFraming/setMax 6000. keV

########

OUTPUT

########
/gate/output/tree/enable
/gate/output/tree/addFileName output/LHCsI.txt
/gate/output/tree/hits/enable
/gate/output/tree/addCollection LESingles
/gate/output/tree/addCollection Singles

@tontyoutoure
Copy link
Contributor

tontyoutoure commented Jun 3, 2023

Can confirm.
I ran valgrind and the following part is what increases as duration of simulation increase:

parts of valgrind output
==72618== 2,844,528 bytes in 118,522 blocks are definitely lost in loss record 22,855 of 22,861
==72618==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==72618==    by 0x359D45: __gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*) (new_allocator.h:114)
==72618==    by 0x358F84: std::allocator_traits<std::allocator<int> >::allocate(std::allocator<int>&, unsigned long) (alloc_traits.h:443)
==72618==    by 0x3584AD: std::_Vector_base<int, std::allocator<int> >::_M_allocate(unsigned long) (stl_vector.h:343)
==72618==    by 0x37E712: std::_Vector_base<int, std::allocator<int> >::_M_create_storage(unsigned long) (stl_vector.h:358)
==72618==    by 0x37E1CA: std::_Vector_base<int, std::allocator<int> >::_Vector_base(unsigned long, std::allocator<int> const&) (stl_vector.h:302)
==72618==    by 0x3A0AFA: std::vector<int, std::allocator<int> >::vector(unsigned long, int const&, std::allocator<int> const&) (stl_vector.h:521)
==72618==    by 0x3A0203: GateOutputVolumeID::GateOutputVolumeID(unsigned long) (GateOutputVolumeID.hh:56)
==72618==    by 0x417BA6: GateDigi::GateDigi(void const*) (GateDigi.cc:45)
==72618==    by 0x5F2AC7: GateReadout::Digitize() (GateReadout.cc:225)
==72618==    by 0x42AC40: GateDigitizerMgr::RunDigitizers() (GateDigitizerMgr.cc:427)
==72618==    by 0x3833AA: GateAnalysis::RecordEndOfEvent(G4Event const*) (GateAnalysis.cc:479)
==72618== 
==72618== 2,844,552 bytes in 118,523 blocks are definitely lost in loss record 22,856 of 22,861
==72618==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==72618==    by 0x359D45: __gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*) (new_allocator.h:114)
==72618==    by 0x358F84: std::allocator_traits<std::allocator<int> >::allocate(std::allocator<int>&, unsigned long) (alloc_traits.h:443)
==72618==    by 0x3584AD: std::_Vector_base<int, std::allocator<int> >::_M_allocate(unsigned long) (stl_vector.h:343)
==72618==    by 0x37E712: std::_Vector_base<int, std::allocator<int> >::_M_create_storage(unsigned long) (stl_vector.h:358)
==72618==    by 0x37E1CA: std::_Vector_base<int, std::allocator<int> >::_Vector_base(unsigned long, std::allocator<int> const&) (stl_vector.h:302)
==72618==    by 0x3A0AFA: std::vector<int, std::allocator<int> >::vector(unsigned long, int const&, std::allocator<int> const&) (stl_vector.h:521)
==72618==    by 0x3A0203: GateOutputVolumeID::GateOutputVolumeID(unsigned long) (GateOutputVolumeID.hh:56)
==72618==    by 0x417BA6: GateDigi::GateDigi(void const*) (GateDigi.cc:45)
==72618==    by 0x61C6F8: GateSpatialResolution::Digitize() (GateSpatialResolution.cc:115)
==72618==    by 0x42AC40: GateDigitizerMgr::RunDigitizers() (GateDigitizerMgr.cc:427)
==72618==    by 0x3833AA: GateAnalysis::RecordEndOfEvent(G4Event const*) (GateAnalysis.cc:479)
==72618== 
==72618== 2,844,624 bytes in 118,526 blocks are definitely lost in loss record 22,857 of 22,861
==72618==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==72618==    by 0x359D45: __gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*) (new_allocator.h:114)
==72618==    by 0x358F84: std::allocator_traits<std::allocator<int> >::allocate(std::allocator<int>&, unsigned long) (alloc_traits.h:443)
==72618==    by 0x3584AD: std::_Vector_base<int, std::allocator<int> >::_M_allocate(unsigned long) (stl_vector.h:343)
==72618==    by 0x37E712: std::_Vector_base<int, std::allocator<int> >::_M_create_storage(unsigned long) (stl_vector.h:358)
==72618==    by 0x37E1CA: std::_Vector_base<int, std::allocator<int> >::_Vector_base(unsigned long, std::allocator<int> const&) (stl_vector.h:302)
==72618==    by 0x3A0AFA: std::vector<int, std::allocator<int> >::vector(unsigned long, int const&, std::allocator<int> const&) (stl_vector.h:521)
==72618==    by 0x3A0203: GateOutputVolumeID::GateOutputVolumeID(unsigned long) (GateOutputVolumeID.hh:56)
==72618==    by 0x417BA6: GateDigi::GateDigi(void const*) (GateDigi.cc:45)
==72618==    by 0x48549F: GateEnergyResolution::Digitize() (GateEnergyResolution.cc:96)
==72618==    by 0x42AC40: GateDigitizerMgr::RunDigitizers() (GateDigitizerMgr.cc:427)
==72618==    by 0x3833AA: GateAnalysis::RecordEndOfEvent(G4Event const*) (GateAnalysis.cc:479)
==72618== 
==72618== 2,844,696 bytes in 118,529 blocks are definitely lost in loss record 22,858 of 22,861
==72618==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==72618==    by 0x359D45: __gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*) (new_allocator.h:114)
==72618==    by 0x358F84: std::allocator_traits<std::allocator<int> >::allocate(std::allocator<int>&, unsigned long) (alloc_traits.h:443)
==72618==    by 0x3584AD: std::_Vector_base<int, std::allocator<int> >::_M_allocate(unsigned long) (stl_vector.h:343)
==72618==    by 0x37E712: std::_Vector_base<int, std::allocator<int> >::_M_create_storage(unsigned long) (stl_vector.h:358)
==72618==    by 0x37E1CA: std::_Vector_base<int, std::allocator<int> >::_Vector_base(unsigned long, std::allocator<int> const&) (stl_vector.h:302)
==72618==    by 0x3A0AFA: std::vector<int, std::allocator<int> >::vector(unsigned long, int const&, std::allocator<int> const&) (stl_vector.h:521)
==72618==    by 0x3A0203: GateOutputVolumeID::GateOutputVolumeID(unsigned long) (GateOutputVolumeID.hh:56)
==72618==    by 0x417BA6: GateDigi::GateDigi(void const*) (GateDigi.cc:45)
==72618==    by 0x37C84A: GateAdder::Digitize() (GateAdder.cc:70)
==72618==    by 0x42AC40: GateDigitizerMgr::RunDigitizers() (GateDigitizerMgr.cc:427)
==72618==    by 0x3833AA: GateAnalysis::RecordEndOfEvent(G4Event const*) (GateAnalysis.cc:479)
==72618== 
==72618== 2,844,696 bytes in 118,529 blocks are definitely lost in loss record 22,859 of 22,861
==72618==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==72618==    by 0x359D45: __gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*) (new_allocator.h:114)
==72618==    by 0x358F84: std::allocator_traits<std::allocator<int> >::allocate(std::allocator<int>&, unsigned long) (alloc_traits.h:443)
==72618==    by 0x3584AD: std::_Vector_base<int, std::allocator<int> >::_M_allocate(unsigned long) (stl_vector.h:343)
==72618==    by 0x37E712: std::_Vector_base<int, std::allocator<int> >::_M_create_storage(unsigned long) (stl_vector.h:358)
==72618==    by 0x37E1CA: std::_Vector_base<int, std::allocator<int> >::_Vector_base(unsigned long, std::allocator<int> const&) (stl_vector.h:302)
==72618==    by 0x3A0AFA: std::vector<int, std::allocator<int> >::vector(unsigned long, int const&, std::allocator<int> const&) (stl_vector.h:521)
==72618==    by 0x3A0203: GateOutputVolumeID::GateOutputVolumeID(unsigned long) (GateOutputVolumeID.hh:56)
==72618==    by 0x417BA6: GateDigi::GateDigi(void const*) (GateDigi.cc:45)
==72618==    by 0x483461: GateEnergyFraming::Digitize() (GateEnergyFraming.cc:86)
==72618==    by 0x42AC40: GateDigitizerMgr::RunDigitizers() (GateDigitizerMgr.cc:427)
==72618==    by 0x3833AA: GateAnalysis::RecordEndOfEvent(G4Event const*) (GateAnalysis.cc:479)
After a while I realize the cause of the problem is kind simple. A lot of digitizer ( not sure if it's all of them) said
GateDigi* inputDigi = new GateDigi();

in their ::Digitize() method. And without delete.

It could be patched with ease.

tontyoutoure pushed a commit to tontyoutoure/Gate that referenced this issue Jun 3, 2023
@tontyoutoure
Copy link
Contributor

Wow it turn outs that this pointer will be assigned other values and should not allocate anything in the first place.
Make a PR hope it will be merged asap.

@tontyoutoure
Copy link
Contributor

tontyoutoure commented Jun 3, 2023

It seems there are more leak other than the one showed above. I'll try to find it.

Edit: Turns out to be it's something else. The fix above should be sufficient.

kochebina added a commit that referenced this issue Jun 7, 2023
@tontyoutoure
Copy link
Contributor

You can now git pull origin develop in your virtual machine ~/Software/Gate/src dir and make in ~/Software/Gate/bin dir to fix the problem. @Fantasticlyy

@dsarrut
Copy link
Contributor

dsarrut commented Jun 8, 2023

done #619

@dsarrut dsarrut closed this as completed Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants