Memory leak when assigning AP2 vectors to branches in PyROOT examples

Hi Allpix Squared team,
I am a new user and I am working on simulating an x-ray tube. The framework is easy to understand and use, so, many thanks for this!!!

At the moment I am facing some troubles with analyzing the data with PyROOT (python 3.11.5 and ROOT 6.28/06). I am using a code very similar to this example (tools/root_analysis_macros/ · master · Allpix Squared / Allpix Squared · GitLab) and since I have a rather large root file to go over (some million of events) I could track down a memory leak to these lines where the AP2 vectors are assigned to branches (tools/root_analysis_macros/ · master · Allpix Squared / Allpix Squared · GitLab). Have you noticed something similar? If yes, is there another way to access the TNonSplitBrowsable objects under the main TBranchElements of the TTrees?

Hi @ggiakous ,

thank you very much for the kind words! We’re happy to hear that new users find an easy entry point to Allpix Squared!

To be very honest, these are not the most maintained parts of the repository and serve as an example. I have used and adapted it several times, but not with the large amounts of data you seem to be dealing with.
It would be interesting to understand whether this memory leak happens on the “ROOT” side or the “user” side. Did you try to delete the vectors before overwriting their pointer per loop? There’s a bit of help at least for C based analyses here (section GetEntry), did you try something similar?