Skip to content
Snippets Groups Projects
Commit 5195048b authored by scott snyder's avatar scott snyder
Browse files

LArTrackingGeometry: Fix memory leaks

CompactBinnedArray maps bins in some coordinates to a vector of pointers
to objects.  It does not own this objects.

BinnedMaterial uses CompactBinnedArray, with the object in question
being a pair<> object.

When a BinnedMaterial is constructed, it takes a vector of pointers
to these pairs.  It does not take ownership of this pairs, but just
passes them to the CompactBinnedArray.

The callers of BinnedMaterial also do not take ownership of these pairs.
So they are presently leaked.

Further, BinnedMaterial can't just delete them, because these pairs
get shared between multiple BinnedMaterial instances.

We restructure like this.

BinnnedMaterial now gets a vector of pairs, which it saves as a member.
The CompactBinnedArray is then constructed to that it points at the
pairs in this vector.  BinnedMaterial now effectively owns the pairs.
These are now duplicated in each BinnedMaterial, but that should be ok.
We also need to extend CompactBinnedArray so that we can give it
a new vector of object pointers when it is cloned.

cf ATLASRECTS-5831.
parent ed278d16
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment