Message: Re: free hits? - solved after all, but still i don't understand why Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Note Re: free hits? - solved after all, but still i don't understand why 

Keywords: hits delete
Forum: Hits, Digitization and Pileup
Re: None free hits? (Hans Boie)
Re: Idea Re: free hits? (Makoto Asai)
Date: 01 Feb, 2005
From: Hans Boie <hans.boie@mpi-hd.mpg.de>

By chance i happend to solve my memory leak problem.

My Initialize() method of the SensitiveDetector class formerly looked like following:

> void BraZSensitiveDetector::Initialize(G4HCofThisEvent* evnt)
> {
>   static G4int HCID = -1;
>   if(HCID<0)
>     HCID = G4SDManager::GetSDMpointer()->GetCollectionID(HC_name);
>   evnt->AddHitsCollection( HCID, hitsCollection );
>
>   if(histoManager)
>     histoManager->SetSiHitsCollection(det_nb, hitsCollection);
> }

So i collect the id of the HitsCollection only once - as done in various examples. I work with several detectors which all have their own HitsCollection. But as described while running the simulation the needed memory grew bigger and bigger.

Now i changed the code as follows:

> void BraZSensitiveDetector::Initialize(G4HCofThisEvent* evnt)
> {
>   hitsCollection = new BraZHitsCollection
>                           (SensitiveDetectorName, HC_name); 
>   G4int HCID = G4SDManager::GetSDMpointer()->GetCollectionID(HC_name);
>   evnt->AddHitsCollection(HCID, hitsCollection);
>
>   if(histoManager)
>     histoManager->SetSiHitsCollection(det_nb, hitsCollection);
> }

And it works quite nice. This really seems to be very strange and i don't understand why this works and the old one doesn't!

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

 Add Message Add Message
to: "Re: free hits? - solved after all, but still i don't understand why"

 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 ]