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>

> 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 got problems sending HN, sorry if this is the n-th iteration for this message...)

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

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

1 Agree: Re: Usage of memory in a sensitive detector   (Mario - 29 Nov, 2010)
 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 ]