Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some mem leaks corrections #624

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions source/digits_hits/src/GateSpatialResolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ GateSpatialResolution::GateSpatialResolution(GateSinglesDigitizer *digitizer, G4
m_fwhmY(0),
m_fwhmZ(0),
m_IsConfined(true),
m_Navigator(0),
m_Touchable(0),
m_systemDepth(-1),
m_outputDigi(0),
Expand All @@ -60,13 +59,15 @@ GateSpatialResolution::GateSpatialResolution(GateSinglesDigitizer *digitizer, G4
G4String colName = digitizer->GetOutputName() ;
collectionName.push_back(colName);
m_Messenger = new GateSpatialResolutionMessenger(this);
m_Navigator = new G4Navigator();

}


GateSpatialResolution::~GateSpatialResolution()
{
delete m_Messenger;

delete m_Navigator;
}


Expand Down Expand Up @@ -188,7 +189,6 @@ void GateSpatialResolution::Digitize()
// Do not use from TransportationManager as it is not recommended
G4Navigator *navigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
G4VPhysicalVolume *WorldVolume = navigator->GetWorldVolume();
m_Navigator = new G4Navigator();
m_Navigator->SetWorldVolume(WorldVolume);

G4VPhysicalVolume* PV = m_Navigator->LocateGlobalPointAndSetup(m_outputDigi->GetGlobalPos());
Expand All @@ -199,6 +199,8 @@ void GateSpatialResolution::Digitize()
{
UpdateVolumeID();
}


m_OutputDigiCollection->insert(m_outputDigi);


Expand Down
9 changes: 7 additions & 2 deletions source/digits_hits/src/GateToASCII.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ GateToASCII::GateToASCII(const G4String& name, GateOutputMgr* outputMgr, DigiMod

GateToASCII::~GateToASCII()
{
// for (size_t i=0; i<m_outputChannelList.size() ; ++i )
// delete m_outputChannelList[i];
//for (size_t i=0; i<m_outputChannelList.size() ; ++i )
// delete m_outputChannelList[i];

delete m_asciiMessenger;

Expand Down Expand Up @@ -335,6 +335,8 @@ void GateToASCII::RegisterNewSingleDigiCollection(const G4String& aCollectionNam

// G4cout << " GateToASCII::RegisterNewSingleDigiCollection \n";
m_asciiMessenger->CreateNewOutputChannelCommand(singleOutputChannel);

//delete singleOutputChannel;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Expand All @@ -347,6 +349,9 @@ void GateToASCII::RegisterNewCoincidenceDigiCollection(const G4String& aCollecti

// G4cout << " GateToASCII::RegisterNewCoincidenceDigiCollection \n";
m_asciiMessenger->CreateNewOutputChannelCommand(coincOutputChannel);
// delete coincOutputChannel;


}

long GateToASCII::VOutputChannel::m_outputFileSizeLimit = 2000000000;
Expand Down
2 changes: 2 additions & 0 deletions source/digits_hits/src/GateToASCIIMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ void GateToASCIIMessenger::CreateNewOutputChannelCommand(GateToASCII::VOutputCha
newCmd->SetGuidance(aGuidance.c_str());
newCmd->SetGuidance("1. true/false");
OutputChannelCmdList.push_back( newCmd );

//delete newCmd;
}
//--------------------------------------------------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions source/digits_hits/src/GateToBinary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ void GateToBinary::RegisterNewSingleDigiCollection(
m_outputChannelVector.push_back( singleOutputChannel );

m_binaryMessenger->CreateNewOutputChannelCommand( singleOutputChannel );

//delete singleOutputChannel;
}


Expand All @@ -437,6 +439,8 @@ void GateToBinary::RegisterNewCoincidenceDigiCollection(
m_outputChannelVector.push_back( coincOutputChannel );

m_binaryMessenger->CreateNewOutputChannelCommand( coincOutputChannel );

//delete coincOutputChannel;
}

void GateToBinary::VOutputChannel::OpenFile(
Expand Down
2 changes: 2 additions & 0 deletions source/digits_hits/src/GateToBinaryMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ void GateToBinaryMessenger::CreateNewOutputChannelCommand(

// Add the new command
m_outputChannelCmd.push_back( newCmd );

//delete newCmd;
}

G4bool GateToBinaryMessenger::IsAnOutputChannelCmd( G4UIcommand* command )
Expand Down
3 changes: 3 additions & 0 deletions source/digits_hits/src/GateToRootMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ GateToRootMessenger::~GateToRootMessenger()
delete CoincidenceMaskCmd;
delete SingleMaskCmd;
delete SaveRndmCmd;



for (size_t i = 0; i<OutputChannelCmdList.size() ; ++i)
delete OutputChannelCmdList[i];
}
Expand Down
9 changes: 9 additions & 0 deletions source/digits_hits/src/GateToTreeMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ GateToTreeMessenger::GateToTreeMessenger(GateToTree *m) :
G4String s = "/gate/output/tree/hits/branches/" + name + "/disable";
auto c = new G4UIcmdWithoutParameter(s, this);
m_maphits_cmdParameter_toTreeParameter.emplace(c, name);
delete c;
}

for(auto &&m: m_gateToTree->getOpticalParamsToWrite())
Expand All @@ -70,6 +71,7 @@ GateToTreeMessenger::GateToTreeMessenger(GateToTree *m) :
G4String s = "/gate/output/tree/optical/branches/" + name + "/disable";
auto c = new G4UIcmdWithoutParameter(s, this);
m_mapoptical_cmdParameter_toTreeParameter.emplace(c, name);
delete c;
}


Expand All @@ -79,6 +81,7 @@ GateToTreeMessenger::GateToTreeMessenger(GateToTree *m) :
G4String s = "/gate/output/tree/Singles/branches/" + name + "/disable";
auto c = new G4UIcmdWithoutParameter(s, this);
m_mapsingles_cmdParameter_toTreeParameter.emplace(c, name);
delete c;
}

for(auto &&m: m_gateToTree->getCoincidencesParamsToWrite())
Expand All @@ -87,6 +90,7 @@ GateToTreeMessenger::GateToTreeMessenger(GateToTree *m) :
G4String s = "/gate/output/tree/Coincidences/branches/" + name + "/disable";
auto c = new G4UIcmdWithoutParameter(s, this);
m_mapscoincidences_cmdParameter_toTreeParameter.emplace(c, name);
delete c;
}


Expand All @@ -104,6 +108,11 @@ GateToTreeMessenger::~GateToTreeMessenger()
delete m_enableHitsOutput;
delete m_disableHitsOutput;

delete m_enableOpticalDataOutput;
delete m_disableOpticalDataOutput;
delete m_addCollectionCmd;


}

void GateToTreeMessenger::SetNewValue(G4UIcommand *icommand, G4String string)
Expand Down