Yet another memory question

From: Chris Jillings (chris@owl.phy.queensu.ca)
Date: Wed Jul 22 1998 - 19:55:05 MEST


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        =
=                                                               =
=================================================================



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:35 MET