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>

This is a multi-part message in MIME format.
--------------060104050302080601000105
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

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,

(Apparently, a first attempt of this message did not get through, sorry 
if this comes twice...)

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


--------------060104050302080601000105
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <div class="moz-text-flowed" style="font-family: -moz-fixed;
      font-size: 13px;" lang="x-western">Le 29/11/2010 13:21, Mario a
      &eacute;crit :
      <br>
      <blockquote type="cite" style="color: rgb(0, 0, 0);">G4bool
        scintillatorFiberSD::ProcessHits(G4Step*
        aStep,G4TouchableHistory*)
        <br>
        {
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scintillatorFiberHit* newHit = new
        scintillatorFiberHit();
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Only reading hits where OpWLS-Photons are produced
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        if(aStep-&gt;GetPostStepPoint()-&gt;GetProcessDefinedStep()-&gt;GetProcessName()
        == "OpWLS" ){
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newHit-&gt;SetTrackID&nbsp;
        (aStep-&gt;GetTrack()-&gt;GetTrackID());
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newHit-&gt;SetPos&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (aStep-&gt;GetPostStepPoint()-&gt;GetPosition());
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
newHit-&gt;SetProcessName(aStep-&gt;GetPostStepPoint()-&gt;GetProcessDefinedStep()-&gt;GetProcessName());<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FiberCollection-&gt;insert( newHit );
        <br>
        }
        <br>
        <br>
        &nbsp;&nbsp; return true;
        <br>
        }
        <br>
      </blockquote>
      <br>
      Hello Mario,<br>
      <br>
      (Apparently, a first attempt of this message did not get through,
      sorry if this comes twice...)<br>
      <br>
      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-&gt;... == "OpWLS") is satisfied.
      Please try to move the line
      <br>
      <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scintillatorFiberHit* newHit = new
      scintillatorFiberHit();
      <br>
      <br>
      inside the block of the above "if" statement.
      <br>
      <br>
      Cheers,
      <br>
      Marc
      <br>
      <br>
    </div>
  </body>
</html>

--------------060104050302080601000105--

 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 ]