Problem 865

Summary: G4Transportation seems to have memory leak
Product: Geant4 Reporter: yoshinori.sato
Component: processes/transportationAssignee: John Apostolakis <John.Apostolakis>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.0   
Hardware: PC   
OS: Linux   

Description yoshinori.sato 2006-04-28 00:49:43 CEST
Dear those who are concerened in GEATN4 development,

My debugging with valgrind tells that there is a memory leak in
G4Navigator.icc::CreateTouchableHistory().

==14174== 116 bytes in 1 blocks are definitely lost in loss record 168 of 269
==14174==    at 0x1B904AFB: operator new(unsigned) (vg_replace_malloc.c:133)
==14174==    by 0x81F097B: G4Navigator::CreateTouchableHistory() const
(G4Navigator.icc:283)
==14174==    by 0x825FD58:
G4Navigator::LocateGlobalPointAndUpdateTouchableHandle(CLHEP::Hep3Vector const&,
CLHEP::Hep3Vector const&, G4ReferenceCountedHandle<G4VTouchable>&, bool)
(G4Navigator.cc:521)
==14174==    by 0x81CB620: G4Transportation::PostStepDoIt(G4Track const&, G4Step
const&) (G4Transportation.cc:600)

I cannot fully trace G4Transportation::PostStepDoIt, but seems that the private
member "fCurrentTouchableHandle" is not cleared in the private menber
"fParticleChange" in G4Transportation.cc.

The memory leak is not critically severe, but I would like to ask you to fix it.

Sincerely,

Yoshinori Sato
Comment 1 John Apostolakis 2006-05-08 04:08:59 CEST
A simple inspection shows that indeed the destructor does not clear the memory
for the fCurrentTouchableHandle data member.  We will correct it in the next
version.
Thank you and best regards,
John Apostolakis
Comment 2 yoshinori.sato 2006-05-08 04:47:59 CEST
Dear John and others,

Thank you for identifing the problem.
Please tell me where and how to fix the memory leak in G4Transportation.cc.
Is it O.K. to add "delete fCurrentTouchableHandle" in the destructor ?

Sincerely,

Yoshinori Sato
Comment 3 John Apostolakis 2006-12-20 15:29:59 CET
We have included a fix for this problem in release 8.2.
Please see
http://www-geant4.kek.jp/lxr/source/processes/transportation/src/G4Transportation.cc?v=8.2

Best regards, John Apostolakis