_Geant4 Version: geant4-v10.7.4
_Operating System: MacOS 13.6.4 (22G513)
_Compiler/Version: GNU Make 3.81
_CMake Version: 3.28.0-rc5
Starting several run in a loop (see code portion below), I get a memory leak and the process killed at a certain point by the OS. I need to re-initilize the geometry at each run, and I assume that the old one is kept into memory. For this the leak. Am I wrong? How could solve this (or the possible source of mistake you may spot)
Thanks,
David
below how I loop
for(int i = first_step; i < primPos; i++){
DataManager* man = new DataManager;
G4int primStep = 5*i; //each 5 mm for 44 position = 220 mm
if (i==first_step)
runManager->SetUserInitialization(new PhysicsList);
for(int j=0; j<detPos; j++){
int position = j; // 8 for test, target center
snprintf(name,100,"G4SHADES_gasTarget_extended_primPos%i_detPos%i.root",(110-primStep),position);
// snprintf(name,100,“test”);
runManager->SetUserInitialization(new DetectorConstruction(man,position)); // 0->14 complete scan
runManager->SetUserAction(new PrimaryGeneratorAction((double)primStep, man)); // 0->220 full target length
runManager->SetUserAction(new RunAction(man, name));
runManager->SetUserAction(new EventAction(man));
runManager->Initialize();
runManager->ReinitializeGeometry();
runManager->BeamOn(1000000);
}
delete man;
}