Main Page | Compound List | File List | Compound Members | File Members | Related Pages

leaktest.cxx

Go to the documentation of this file.
00001 // Test routine to make sure there are no memory leaks when creating
00002 // and deleting mcRootData objects.
00003 // To Run:
00004 // 1) Make sure mcRootData.dll is in your ROOT library path
00005 //    a) This can be done by either modifying your local .rootrc file 
00006 //       Unix.*.Root.DynamicPath:    $(ROOTANALYSIS)/lib
00007 //       WinNT.*.Root.DynamicPath:   $(ROOTANALYSIS)/lib
00008 //   OR
00009 //    b) Copy mcRootData.so (or .dll) into the directory from where you start ROOT.
00010 // 2) You want to make sure that memory statistics are kept in ROOT by modifying your
00011 //    local .rootrc file, and setting:
00012 //    Root.MemStat:            1
00013 //    Root.ObjectStat:         1
00014 // 3) Start ROOT
00015 // 4) At the ROOT prompt, type:  ".x leaktest.cxx" 
00016 
00017 {
00018     UInt_t numEvents = 500;
00019     UInt_t numParticles = 100;
00020     UInt_t runNum = 1;
00021         Int_t sourceId = 7;
00022         UInt_t sequence = 4;
00023 
00024     gObjectTable->Print();
00025     
00026     if (!strcmp(gSystem->GetName(), "WinNT")) {
00027       gSystem->Load("mcRootData.dll");
00028     } else {
00029       gSystem->Load("libmcRootData.so");
00030     }
00031     TFile *f =  new TFile("mc.root", "RECREATE");
00032     TTree *t = new TTree("Mc", "Mc");
00033     McEvent *ev = new McEvent();
00034     t->Branch("McEvent", "McEvent", &ev, 64000, 1);
00035     
00036     gObjectTable->Print();
00037     TRandom randGen ;
00038     RAND_NUM = randGen.Rndm() ;
00039 
00040     Int_t ievent;
00041     for (ievent = 0; ievent < numEvents; ievent++) {
00042         ev->Fake(ievent,runNum,RAND_NUM) ;
00043 
00044         t->Fill();
00045         ev->Clear();
00046     }
00047     
00048     delete ev;
00049     
00050     printf("Here is the object table after creating events, storing them to file and deleting the objects\n");
00051     gObjectTable->Print();
00052     
00053     f->Write();
00054     f->Close();
00055     delete f;
00056     
00057 }
00058 
00059 

Generated on Tue Dec 11 16:28:52 2007 by doxygen 1.3.3