Message: Re: Memory Leak/Implementation of THitsCollection Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Ok Re: Memory Leak/Implementation of THitsCollection 

Forum: Hits, Digitization and Pileup
Re: Sad Memory Leak/Implementation of THitsCollection (Nicole Ackerman)
Re: None Re: Memory Leak/Implementation of THitsCollection (Tsukasa Aso)
Re: More Re: Memory Leak/Implementation of THitsCollection (Nicole Ackerman)
Date: 15 May, 2012
From: Nicole Ackerman <Nicole Ackerman>

I seem to have fixed my problem by following Example N05. N02 and N05 do the AddHitsCollection a bit differently - the code in N05 is working for me. The scope of HCID is changed and the EndOfEvent now has the AddHitsCollection:

void NucSD::EndOfEvent(G4HCofThisEvent* HCE) {

  //from ExN05
  if(HCID<0)
  { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
  HCE->AddHitsCollection( HCID, trackerCollection ); 
}

Now my debug output shows that the memory location of my two collections are alternating back and forth:

@@@   NucSD: tracker SD Name: cellDet and CN: cellDet_collection
     trackerC: 0x221c350
@@@   NucSD: tracker SD Name: nucDet and CN: nucDet_collection
     trackerC: 0x221c370
Event number 0 processed.
@@@   NucSD: tracker SD Name: cellDet and CN: cellDet_collection
     trackerC: 0x221c370
@@@   NucSD: tracker SD Name: nucDet and CN: nucDet_collection
     trackerC: 0x221c350
@@@   NucSD: tracker SD Name: cellDet and CN: cellDet_collection
     trackerC: 0x221c350
@@@   NucSD: tracker SD Name: nucDet and CN: nucDet_collection
     trackerC: 0x221c370
@@@   NucSD: tracker SD Name: cellDet and CN: cellDet_collection
     trackerC: 0x221c370
@@@   NucSD: tracker SD Name: nucDet and CN: nucDet_collection
     trackerC: 0x221c350
@@@   NucSD: tracker SD Name: cellDet and CN: cellDet_collection
     trackerC: 0x221c350
@@@   NucSD: tracker SD Name: nucDet and CN: nucDet_collection
     trackerC: 0x221c370

And now valgrind doesn't show a memory leak associated with creating the THitsCollection. I don't fully understand the THitsCollection system, but I think I see why the N05 implementation is "better" than the N02 implementation.

I wanted to post this here in case it helps anyone else running into these problems.

 Add Message Add Message
to: "Re: Memory Leak/Implementation of THitsCollection"

 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 ]