some memory leak 'fixes'

This commit is contained in:
nemu 2009-04-20 14:12:26 +00:00
parent 61f6fd1b9c
commit 99dedce540
8 changed files with 57 additions and 17 deletions

View File

@ -42,7 +42,7 @@ endif
# -- Linux # -- Linux
ifeq ($(OS),LINUX) ifeq ($(OS),LINUX)
CXX = g++ CXX = g++
CXXFLAGS = -O3 -Wall -Wno-trigraphs -fPIC CXXFLAGS = -g -O3 -Wall -Wno-trigraphs -fPIC
PMUSRPATH = ../include PMUSRPATH = ../include
MNPATH = $(ROOTSYS)/include MNPATH = $(ROOTSYS)/include
GSLPATH = /usr/include/gsl GSLPATH = /usr/include/gsl

View File

@ -103,6 +103,16 @@ PFitter::~PFitter()
{ {
fCmdList.clear(); fCmdList.clear();
if (fMnUserParamState) {
delete fMnUserParamState;
fMnUserParamState = 0;
}
if (fFcnMin) {
delete fFcnMin;
fFcnMin = 0;
}
if (fFitterFcn) { if (fFitterFcn) {
delete fFitterFcn; delete fFitterFcn;
fFitterFcn = 0; fFitterFcn = 0;
@ -831,13 +841,17 @@ bool PFitter::ExecuteSave()
hcorr->Draw("COLZTEXT"); hcorr->Draw("COLZTEXT");
else else
hcorr->Draw("COLZ"); hcorr->Draw("COLZ");
ccorr->Write(); ccorr->Write("ccorr", TObject::kOverwrite, sizeof(ccorr));
ff.Close(); ff.Close();
// clean up // clean up
if (ccorr) if (ccorr) {
delete ccorr; delete ccorr;
if (hcorr) ccorr = 0;
}
if (hcorr) {
delete hcorr; delete hcorr;
hcorr = 0;
}
} }
parNo.clear(); // clean up parNo.clear(); // clean up
} else { } else {

View File

@ -96,6 +96,11 @@ PMsrHandler::~PMsrHandler()
fPlots.clear(); fPlots.clear();
fStatistic.fStatLines.clear(); fStatistic.fStatLines.clear();
fParamInUse.clear(); fParamInUse.clear();
if (fFuncHandler) {
delete fFuncHandler;
fFuncHandler = 0;
}
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@ -1660,8 +1660,11 @@ bool PRunDataHandler::IsWhitespace(const char *str)
{ {
unsigned int i=0; unsigned int i=0;
while (isblank(str[i]) || (iscntrl(str[i])) && str[i] != 0) while (isblank(str[i]) || iscntrl(str[i])) {
if (str[i] == 0)
break;
i++; i++;
}
if (i == strlen(str)) if (i == strlen(str))
return true; return true;

View File

@ -301,15 +301,8 @@ PTheory::~PTheory()
fLFIntegral.clear(); fLFIntegral.clear();
fDynLFFuncValue.clear(); fDynLFFuncValue.clear();
if (fMul) { // recursive clean up
delete fMul; CleanUp(this);
fMul = 0;
}
if (fAdd) {
delete fAdd;
fAdd = 0;
}
if (fUserFcn) { if (fUserFcn) {
delete fUserFcn; delete fUserFcn;
@ -664,6 +657,30 @@ double PTheory::Func(register double t, const PDoubleVector& paramValues, const
return 0.0; return 0.0;
} }
//--------------------------------------------------------------------------
/**
* <p> Recursively clean up theory
*
* \param theo
*/
void PTheory::CleanUp(PTheory *theo)
{
if (theo->fMul) { // '*' present
CleanUp(theo->fMul);
if (theo->fAdd) {
CleanUp(theo->fAdd);
delete theo;
theo = 0;
}
} else { // '*' NOT present
if (theo->fAdd) {
CleanUp(theo->fAdd);
delete theo;
theo = 0;
}
}
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> * <p>

View File

@ -199,6 +199,7 @@ class PTheory
virtual double Func(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const; virtual double Func(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
private: private:
virtual void CleanUp(PTheory *theo);
virtual int SearchDataBase(TString name); virtual int SearchDataBase(TString name);
virtual void MakeCleanAndTidyTheoryBlock(PMsrLines* fullTheoryBlock); virtual void MakeCleanAndTidyTheoryBlock(PMsrLines* fullTheoryBlock);
virtual void MakeCleanAndTidyPolynom(unsigned int i, PMsrLines* fullTheoryBlock); virtual void MakeCleanAndTidyPolynom(unsigned int i, PMsrLines* fullTheoryBlock);

View File

@ -351,7 +351,7 @@ int main(int argc, char *argv[])
// read input file and write output file // read input file and write output file
char str[256]; char str[256];
int tag; int tag = -1;
bool success = true; bool success = true;
while (!fin.eof() && success) { while (!fin.eof() && success) {
fin.getline(str, sizeof(str)); fin.getline(str, sizeof(str));

View File

@ -123,10 +123,10 @@
</func> </func>
<func> <func>
<name>internFld</name> <name>internFld</name>
<comment>(phase frequency Trate Lrate)</comment> <comment>(fraction phase frequency Trate Lrate)</comment>
<label>internal Lorentz field</label> <label>internal Lorentz field</label>
<pixmap>internalField.png</pixmap> <pixmap>internalField.png</pixmap>
<params>4</params> <params>5</params>
</func> </func>
<func> <func>
<name>TFieldCos</name> <name>TFieldCos</name>