Re: [ROOT] memory hog

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Feb 21 2001 - 16:43:46 MET


Hi Michael,

This clearly indicates that some objects allocated by your Event class
are not deleted.
The result of gObjectTable->Print below shows that you did not activate
the memory statistics collection. By default, Root runs with no memory
run statistics. To activate this collection, do the following:
If you have a file named ".rootrc" in your current directory, add the following
2 lines:
Root.MemStat:            1
Root.ObjectStat:         1

If you do not have this file in your directory, edit $ROOTSYS/system.rootrc
changing these values from 0 to 1.

To tell more about the problem, I need your Event.h and Event.cxx files
and also all the classes referenced by this class.

Let me know.

Rene Brun


Michael Kuss wrote:
> 
> Hi Rooters,
> 
> I write a program which reads events, extracts selected branches, and
> writes the truncated events back to another file.  The program is more or
> less cloned from the copytree2.C example macro at
> http://root.cern.ch/root/html/examples/copytree2.C.html .
> 
> It works, except that it acts as a memory hog, i.e. grows bigger and
> bigger during execution.  The following is an excerpt, the full code is in
> the attachment.
> 
> >>>>>>>>>>>>
> 
>   Int_t maxVirtualSize = 8000000;
> 
>   TROOT rootSys ( "GLAST", "GLAST Event" );
>   TFile* f = new TFile ( file, "read" );
>   TTree* T = (TTree*)f->Get("T");
>   T->SetMaxVirtualSize(maxVirtualSize);
>   Event* event = new Event();
>   T->SetBranchAddress ( "Event", &event );
>   T->SetBranchStatus ( "*", 0 );
>   T->SetBranchStatus ( "m_event", 1 );
>   T->SetBranchStatus ( "m_TKR", 1 );
> 
>   TFile* of = new TFile ( outFile, "recreate", "stripped test beam file" );
>   TTree* oT = T->CloneTree(0);
>   oT->Reset();
>   oT->SetMaxVirtualSize(maxVirtualSize);
>   oT->SetAutoSave(maxVirtualSize);
>   oT->GetBranch("m_event")->SetFile(outFile);
>   oT->GetBranch("m_TKR")->SetFile(outFile);
>   gObjectTable->Print();
>   oT->CopyEntries( T, nEvent );
>   gObjectTable->Print();
> 
>   of->Write();
> 
>   delete of;
>   delete f;
> <<<<<<<<<<<<
> 
> I don't see the memory leak.  The memory is being allocated during
> oT->CopyEntries(), and released on program termination.  The
> gObjectTable->Print() statements enclosing oT->CopyEntries() give
> identical output before and after.
> 
> >>>>>>>>>>>>
> Object statistics
> class                     cnt    on heap     size    total size    heap size
> ============================================================================
> TObject                    42         42       12           504          504
> TOrdCollection              5          5       44           220          220
> TEnv                        1          1       24            24           24
> THashTable                  2          2       40            80           80
> TClassTable                 1          1       12            12           12
> TObjectTable                1          1       24            24           24
> TROOT                       1          0      256           256            0
> THashList                   2          2       48            96           96
> TUnixSystem                 1          1      320           320          320
> ----------------------------------------------------------------------------
> Total:                     56         55      780          1536         1280
> ============================================================================
> <<<<<<<<<<<<
> 
> Looking into the TTree.cxx sources also didn't reveal something
> suspicious.
> 
> I assumed that oT->SetMaxVirtualSize() is limiting the amount of memory
> used, but this does not seem to be the case.  WHAT AM I MISSING?
> 
> Thanks,
> 
> Michael
> 
>   --------------------------------------------------------------------------------
> 
>                           Name: stripEvent.cc
>    stripEvent.cc          Type: Plain Text (TEXT/PLAIN)
>                       Encoding: BASE64
>                    Description: stripEvent.cc



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:37 MET