Disable unused event branches to prevent memory leak#564
Disable unused event branches to prevent memory leak#564cmargalejo wants to merge 4 commits intomasterfrom
Conversation
Yes! I tested these changes and they avoid the memory leak of #542.
But I am concerned this is not true. I use multiple event types stored in the same REST file and all of them can be used. For instance, the REST_ViewEvents.C macro can be used to visualize the different event types of the same event if they are stored in the same REST file. I tried doing exactly this and now it crashes 😢 :. I think we should try to preserve this feature of storing multiple event types for both functionality and retrocompatibility. If we found it is not possible, then discuss which way to go. |
|
I have pushed a fix so that switching between event types in REST_ViewEvents works again with Raw, Hits and Track events. However, switching to a TRestDetectorSignalEvent still crashes... I think it's a separate bug in that class. I'll open an issue. Its in rest-for-physics/detector#125 . |
Investigation started from rest-for-physics/detectorlib#124, where @AlvaroEzq reported the leak from #542 was still present after the destructor fix.
When a REST file stores multiple event types (e.g. Raw → Signal → Hits → Track), only the last one is actually used. But all event branches in the tree were left enabled. Each time
GetEntry()reads the tree, ROOT creates internal objects for the unused branches that never get freed. This causes memory to grow. The fix consists on, after opening the file, disabling all event branches except the one being used.Fixes #542 (hopefully...)