Yet another memory question

Chris Jillings (chris@owl.phy.queensu.ca)
Wed, 22 Jul 1998 13:55:05 -0400 (EDT)


Hi,
I have a memry leak, but I think I'm doing things correctly. Could
someone please point out my error?
The file singlesHists.root is only 5MBytes big. I am compileing the
code on Red Hat Linux 5.1 with ecgs.

Thanks,

Chris

#include "spe.h"
#include "TF1.h"
#include "TCanvas.h"
#include "TApplication.h"
#include "TROOT.h"
#include "TFile.h"
#include "TH1.h"

extern void InitGui();
VoidFuncPtr_t initfuncs[] = { InitGui, 0 };

TROOT root("singles","Charge Singles", initfuncs);

int main(int argc, char** argv){

TApplication theApp("App",&argc,argv);

TFile *hists = new TFile("~/analysis/flashers/highlow/singlesHists.root");
Int_t crate,card,channel;
char pmtName[200];

TH1C* hist = NULL;
TF1* hello = new TF1("hello",spe,0,100,4);
hello->SetParNames("Norm","x-scale","mean","disc");
hello->SetLineWidth(2);
hello->SetLineColor(kBlue);
TDirectory *subdir;

FILE*fitfile = fopen("fitresults.dat","w");

for( crate=0 ; crate<19 ; crate++ ) {
printf("Crate%3d.\n",crate);
for( card=0 ; card<16 ; card++ ) {
printf(" Card%3d\n",card);
for( channel=0 ; channel<32 ; channel++ ) {
sprintf(pmtName,"Crate%3d/Card%3d/QHL: Crate%3d Card%3d Channel%3d",
crate,card,crate,card,channel);
hist = (TH1C*)hists->Get(pmtName);

delete hist;
}
}
}
fclose(fitfile);
printf("All done.\n");

theApp.Run();

}

=================================================================
= =
= Chris Jillings =
= Department of Physics phone/voice mail: (613) 545-6000x4805 =
= Queen's University fax: (613) 545-6813 =
= Kingston, Ontario email: chris@sno.phy.queensu.ca =
= Canada, K7L 3N6 web: http://sno.phy.queensu.ca =
= =
=================================================================