From: ivana Date: Fri, 14 Jan 2011 17:11:28 +0000 (+0000) Subject: Fixing memory leak introduced with rev. 45388 X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=ed90feae1baa231ca41dcd96ed26a90d1fc49c76;p=u%2Fmrichter%2FAliRoot.git Fixing memory leak introduced with rev. 45388 (Philippe P.) --- diff --git a/MUON/AliMUONPreClusterFinder.cxx b/MUON/AliMUONPreClusterFinder.cxx index 1badcb0be30..cbbadf62bb9 100644 --- a/MUON/AliMUONPreClusterFinder.cxx +++ b/MUON/AliMUONPreClusterFinder.cxx @@ -116,27 +116,28 @@ AliMUONPreClusterFinder::AddPad(AliMUONCluster& cluster, AliMUONPad* pad) return; } - cluster.AddPad(*pad); + AliMUONPad* addedPad = cluster.AddPad(*pad); Int_t cathode = pad->Cathode(); TObjArray& padArray = *fPads[cathode]; // WARNING: this Remove method uses the AliMUONPad::IsEqual if that method is // present (otherwise just compares pointers) : so that one must be correct // if implemented ! - padArray.Remove(pad); - // TObject* o = padArray.Remove(pad); + TObject* o = padArray.Remove(pad); // if (!o) // { // AliFatal("Oups. Could not remove pad from pads to consider. Aborting as anyway " // " we'll get an infinite loop. Please check the AliMUONPad::IsEqual method" // " as the first suspect for failed remove"); // } + delete o; + TIter next(&padArray); AliMUONPad* testPad; while ( ( testPad = static_cast(next()))) { - if ( AliMUONPad::AreNeighbours(*testPad,*pad) ) + if ( AliMUONPad::AreNeighbours(*testPad,*addedPad) ) { AddPad(cluster,testPad); } diff --git a/MUON/AliMUONPreClusterFinderV2.cxx b/MUON/AliMUONPreClusterFinderV2.cxx index 46860317328..e3d42f48bd9 100644 --- a/MUON/AliMUONPreClusterFinderV2.cxx +++ b/MUON/AliMUONPreClusterFinderV2.cxx @@ -111,18 +111,16 @@ AliMUONPreClusterFinderV2::AddPad(AliMUONCluster& cluster, AliMUONPad* pad) { /// Add a pad to a cluster - cluster.AddPad(*pad); - pad->SetClusterId(cluster.GetUniqueID()); + AliMUONPad* addedPad = cluster.AddPad(*pad); Int_t cathode = pad->Cathode(); TObjArray& padArray = *fPads[cathode]; - padArray.Remove(pad); - TIter next(&padArray); + delete padArray.Remove(pad); // Check neighbours TObjArray neighbours; - AliMpPad p = fkSegmentations[pad->Cathode()]->PadByIndices(pad->Ix(),pad->Iy(),kTRUE); - Int_t nn = fkSegmentations[pad->Cathode()]->GetNeighbours(p,neighbours); + AliMpPad p = fkSegmentations[cathode]->PadByIndices(addedPad->Ix(),addedPad->Iy(),kTRUE); + Int_t nn = fkSegmentations[cathode]->GetNeighbours(p,neighbours); for (Int_t in = 0; in < nn; ++in) { AliMpPad* p1 = static_cast(neighbours.At(in)); @@ -134,7 +132,7 @@ AliMUONPreClusterFinderV2::AddPad(AliMUONCluster& cluster, AliMUONPad* pad) { if ( !p2->IsUsed() && p2->Ix()==p1->GetIx() && p2->Iy() == p1->GetIy() && - p2->Cathode() == pad->Cathode() ) + p2->Cathode() == cathode ) { AddPad(cluster,p2); } diff --git a/MUON/AliMUONPreClusterFinderV3.cxx b/MUON/AliMUONPreClusterFinderV3.cxx index 6f438b6ff64..f3a19e4744d 100644 --- a/MUON/AliMUONPreClusterFinderV3.cxx +++ b/MUON/AliMUONPreClusterFinderV3.cxx @@ -232,7 +232,8 @@ AliMUONPreClusterFinderV3::AddPad(AliMUONCluster& cluster, AliMUONPad* pad) Int_t cathode = pad->Cathode(); TObjArray& padArray = *fPads[cathode]; - padArray.Remove(pad); + delete padArray.Remove(pad); + TIter next(&padArray); AliMUONPad* testPad; diff --git a/MUON/AliMUONSimpleClusterServer.cxx b/MUON/AliMUONSimpleClusterServer.cxx index 01c5d177972..b0f37fe13d6 100644 --- a/MUON/AliMUONSimpleClusterServer.cxx +++ b/MUON/AliMUONSimpleClusterServer.cxx @@ -353,6 +353,7 @@ AliMUONSimpleClusterServer::UseDigits(TIter& next, AliMUONVDigitStore* digitStor if (!padArray) { padArray = new TObjArray(100); + padArray->SetOwner(kTRUE); fPads[cathode]->Add(detElemId,padArray); } diff --git a/MUON/AlirootRun_MUONtest.sh b/MUON/AlirootRun_MUONtest.sh index 9aa2cc7ed63..7d181d5a8f2 100755 --- a/MUON/AlirootRun_MUONtest.sh +++ b/MUON/AlirootRun_MUONtest.sh @@ -8,7 +8,7 @@ RECONSTRUCTION=1 # will perform reconstruction RAW=1 # will reconstruct from raw data CHECKS=1 # will perform checks SLASHTMP=1 #will use /tmp to put the temporary raw data -NEVENTS=100 # will simulate 100 events +NEVENTS=50 # will simulate 100 events #RECOPTIONS="SAVEDIGITS NOFASTDECODERS" # reconstruction options with non-high performance decoders RECOPTIONS="SAVEDIGITS" # default reconstruction options