Message: Re: Memory leakage using G4WrapperProcess: a user implementation Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Ok Re: Memory leakage using G4WrapperProcess: a user implementation 

Forum: Fast Simulation, Transportation & Others
Re: Question Memory leakage using G4WrapperProcess: a user implementation (Soon Yung Jun)
Date: 07 Aug, 2009
From: Soon Yung Jun <Soon Yung Jun>

It turns out that we should have deleted all secondaries of the original process to clean up leftover memory if the process is changed during stepping. This is a counter clean up for "new G4Track"s added in G4HadronicProcess::FillTotalResult which is called inside G4VParticleChange *G4HadronicProcess::PostStepDoIt once the process defined the step is switched to the parametrization process. So a proposed solution inside G4VParticleChange* GflashHadronWrapperProcess::PostStepDoIt is:

from
        particleChange->Clear();

to
        G4int nsecondary = particleChange->GetNumberOfSecondaries();
        for(G4int DSecLoop=0 ; DSecLoop< nsecondary ; DSecLoop++){
          G4Track* secondaryTrack = particleChange->GetSecondary(DSecLoop);
          delete secondaryTrack;
        }
        particleChange->Clear();

before switching to the parametrized process, i.e., particleChange = fProcess->PostStepDoIt(track,step). In other words, particleChange->Clear() is just setting theNumberOfSecondary=0, but not responsible for deleting objects (secondary tracks). With the proposed addition, the observed memory leak is disappeared.

Regards, ---Soon

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 News: Re: Memory leakage using G4WrapperProcess: a user implementation   (Vladimir Ivanchenko - 12 Aug, 2009)
 Add Message Add Message
to: "Re: Memory leakage using G4WrapperProcess: a user implementation"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]