Skip to content

Commit 2867e5b

Browse files
committed
Improve memory management on the Python side
Improve memory management on the Python side to rely less on the heuristic memory policy.
1 parent 6a5a27e commit 2867e5b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/ShapeTools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ def getPdf(self, channel, process, _cache=None):
909909
stderr.write("Warning: the shapeN implementation in RooStats and L&S are different\n")
910910
pdfs = ROOT.RooArgList(nominalPdf) if self.options.useHistPdf == "always" else ROOT.TList()
911911
if self.options.useHistPdf != "always":
912+
ROOT.SetOwnership(nominalPdf, False)
912913
pdfs.Add(nominalPdf)
913914
coeffs = ROOT.RooArgList()
914915
minscale = 1
@@ -917,6 +918,8 @@ def getPdf(self, channel, process, _cache=None):
917918
pdfs.add(pdfUp)
918919
pdfs.add(pdfDown)
919920
else:
921+
ROOT.SetOwnership(pdfUp, False)
922+
ROOT.SetOwnership(pdfDown, False)
920923
pdfs.Add(pdfUp)
921924
pdfs.Add(pdfDown)
922925
if scale == 1:
@@ -949,6 +952,7 @@ def getPdf(self, channel, process, _cache=None):
949952
maxbins = 0
950953
for i in range(pdfs.GetSize()):
951954
rebinned = self.rebinH1(pdfs.At(i))
955+
ROOT.SetOwnership(rebinned, False)
952956
rebins.Add(rebinned)
953957
maxbins = max(maxbins, rebinned._original_bins)
954958
if channelBinParFlag:
@@ -1264,6 +1268,7 @@ def shape2Pdf(self, shape, channel, process, _cache=None):
12641268
if self.options.useHistPdf == "never":
12651269
shape = self.rebinH1(shape)
12661270
tlist = ROOT.TList()
1271+
ROOT.SetOwnership(shape, False)
12671272
tlist.Add(shape)
12681273
if channelBinParFlag:
12691274
rhp = ROOT.CMSHistFunc(

0 commit comments

Comments
 (0)