Message: Re: Usage of memory in a sensitive detector Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Usage of memory in a sensitive detector 

Forum: Run Management
Re: Question Usage of memory in a sensitive detector (Mario)
Date: 29 Nov, 2010
From: Marc Verderi <Marc Verderi>

Le 29/11/2010 13:21, Mario a écrit :
> G4bool scintillatorFiberSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
> {
>          scintillatorFiberHit* newHit = new scintillatorFiberHit();
>          // Only reading hits where OpWLS-Photons are produced
>          if(aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "OpWLS" ){
>          newHit->SetTrackID  (aStep->GetTrack()->GetTrackID());
>          newHit->SetPos      (aStep->GetPostStepPoint()->GetPosition());
>          newHit->SetProcessName(aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName());
>          FiberCollection->insert( newHit );
> }
>
>    return true;
> }

Hello Mario,

I believe you have a memory leak in above code : you create a "newHit" 
each time ProcessHits is called, but you see that this newHit is passed 
to the collection FiberCollection only in the case your condition if 
(aStep->... == "OpWLS") is satisfied. Please try to move the line

             scintillatorFiberHit* newHit = new scintillatorFiberHit();

inside the block of the above "if" statement.

Cheers,
Marc

 Add Message Add Message
to: "Re: Usage of memory in a sensitive detector"

 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 ]