I am afraid that putting the python logic of the loop into a C++ function is not really a solution and straightforward. I would need to copy all the parameters used in the loop to the wrapper function. And I would have to do it differently for all the different loops.
Is there any other possibility to convert std::map<int,float> to something else in the wrapper function which could be returned to the python world without memory explosion?
allChannels = aHit.GetAllSignals() # where GetAllSignals() returns std::map<int,float>
for c in allChannels:
channel = barnSiPMsnSides + c
rc = h[‘hit_’+str(s)+str(l)].Fill( int(channel))
rc = h[‘bar_’+str(s)+str(l)].Fill(bar)
if s==2 and smallSiPMchannel(c) : rc = h[‘sigS_’+str(s)+str(l)].Fill(c)
If I create an iterator for an std::vector of e.g. ints in a hot loop I don’t see the same leak as for std::map (I do see it for an std::list too, for example). So it must be related to the way the iterators are implemented for those std containers (vector has its own implementation). I’ll report when I have news.