Repository navigation
Conversation
jmcarcell
requested review from
guitargeek,
siliataider and
vepadulano
as code owners
October 22, 2026 12:37
…t are not owned by the directory
vepadulano
requested changes
Oct 22, 2026
vepadulano
left a comment
Member
There was a problem hiding this comment.
Thank you! In principle LGTM, but see some comments for the tests
Co-authored-by: Vincenzo Eduardo Padulano <v.e.padulano@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull request:
Changes or fixes:
TDirectoryFile.Getin Python reads the object withGetObjectChecked()and binds the returned pointer without taking ownership. Objects that are not added to the directory's list are therefore never deleted. This covers non-TObjects likestd::vectororROOT::RNTuple, and TObjects withoutDirectoryAutoAdd, likeTGraphorTObjString. CallingGetagain creates a new copy each time, so memory grows. For example, reading the RNTuple anchor of a file:Python now takes ownership of the returned object, except when the directory holds it in its list. That is the case for histograms, trees and subdirectories, which keep being owned by the directory as before. The fallback for when no key is found is not changed, because it returns objects that are already in memory and owned by someone else. Checking the directory's list (a
THashList) adds about 4 µs to eachGetcall, and this does not depend on the number of objects in the directory.I added a test to
tdirectory_tfile.pythat checks that aTGraph, aTObjStringand astd::vectorread withGetare owned by Python, and that aTH1F, aTTreeand a subdirectory are not and are still usable from the directory after the Python object is deleted. The test fails without the fix.Checklist:
I also checked that calling
Getmany times no longer makes memory grow forTGraph,TObjString,std::vectorandRNTuple, and thattdirectory_tfile.pypasses under ASan with no double deletes.This PR fixes #16178