More Memory Leaks

By doing:

for (int i = 0; i < 100; i++)
{
                if(tree1)
                {
                        delete branch1;
                        branch1 = 0;
                        tree1->GetEntry(i);
                }
                if(tree2)
                {
                        delete branch2;
                        branchProc = 0;
                        tree2->GetEntry(i);
                }

I got (and the leak only appears when both GetEntry(i) are declared):

==14903== 4 bytes in 1 blocks are definitely lost in loss record 7,150 of 99,159
==14903==    at 0x40249C4: operator new[](unsigned int) (vg_replace_malloc.c:343)
==14903==    by 0x41C7E25: TRefTable::ExpandPIDs(int) (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libCore.so.5.28)
==14903==    by 0x41C82B0: TRefTable::AddInternalIdxForPID(TProcessID*) (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libCore.so.5.28)
==14903==    by 0x41C8473: TRefTable::GetInternalIdxForPID(TProcessID*) const (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libCore.so.5.28)
==14903==    by 0x41C84E3: TRefTable::ReadBuffer(TBuffer&) (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libCore.so.5.28)
==14903==    by 0x584F0FE: TBranchRef::ReadLeavesImpl(TBuffer&) (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libTree.so.5.28)
==14903==    by 0x582E001: TBranch::GetEntry(long long, int) (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libTree.so.5.28)
==14903==    by 0x584F48A: TBranchRef::Notify() (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libTree.so.5.28)
==14903==    by 0x41C7B16: TRefTable::Notify() (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libCore.so.5.28)
==14903==    by 0x41C5F03: TRefArray::GetFromTable(int) const (in /afs/slac.stanford.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib/libCore.so.5.28)
==14903==    by 0x6E7E38F: EXOTRefArray::At(int) const (EXOTRefArray.cc:32)
==14903==    by 0x6EA884B: EXOUWireSignal::RecursiveRemove(TObject*) (EXOUWireSignal.cc:73)

Thanks.

If you want somebody to help you on a forum, please, post the minimal working code sample reproducing your problem, otherwise, it’s impossible to guess anything from the ‘code’ you posted here.

I cannot seem to resolve what exactly caused the leak, but removing the delete and setnull code seem to solve the problem in the above case.