Hello all,
Evaluating memory leakage in my G4 application, I have found few suspicions places which eat space…
// ********************************************************************
#ifndef G4AnalysisUtilities_h
#define G4AnalysisUtilities_h 1
// Get short hnType from the tools object
template
G4String GetHnType()
{
// tools::histo::h1d etc.
G4String hnTypeLong = HT::s_class();
// tools::histo::h1d → h1 etc.
return hnTypeLong.substr(14, 2);
}
// ********************************************************************
#ifndef G4ParticleHPList_h
#define G4ParticleHPList_h 1
…
class G4ParticleHPList
{
public:
G4ParticleHPList()
{
theData = new G4double[2];
nPoints=2;
nEntries=0;
theLabel=0.0;
}
~G4ParticleHPList()
{
delete [] theData;
}
….
// ********************************************************************
#ifndef G4ParticleHPContAngularPar_h
#define G4ParticleHPContAngularPar_h 1
…
class G4ParticleHPContAngularPar
{
G4ParticleHPContAngularPar(G4ParticleHPContAngularPar & val)
{
…
theAngular = new G4ParticleHPList[nEnergies];
…
}
~G4ParticleHPContAngularPar()
{
if (theAngular !=0 ) delete [] theAngular;
if (fCache.Get() != 0) delete fCache.Get();
}
but in the presentation “Improving memory handling in Geant4 MT cache, TLS singletons, garbage collection” A. Dotti (SLAC) it is mentioned that for such code it is recommended to use Simplified “garbage collection”: G4AutoDelete::Register(aData); instead of delete[] in destructors…
Does it a real memory issue or the reality is more complex one than we expect?
Sincerely Yours,
Vyacheslav