Skip to content

[Root7] A path to reducing global memory management.#18083

Draft
hageboeck wants to merge 12 commits intoroot-project:masterfrom
hageboeck:root7-memoryManagement
Draft

[Root7] A path to reducing global memory management.#18083
hageboeck wants to merge 12 commits intoroot-project:masterfrom
hageboeck:root7-memoryManagement

Conversation

@hageboeck
Copy link
Member

@hageboeck hageboeck commented Mar 20, 2025

This is a longer-term effort to update ROOT to work both with implicit and explicit object ownership (i.e. whether THx and similar are owned by gDirectory). The branch started by switching off this ownership and fixing all failing tests. These fixes will be done in a way that the code works both with and without implicit ownership, and will be split off into other PRs to keep the review load manageable. Once that's done, the final names and implementations of the ownership-related functions will be decided here.

TODOs:

Note: No need to review until the following PRs are merged:

@github-actions
Copy link

github-actions bot commented Mar 21, 2025

Test Results

    22 files      22 suites   3d 7h 51m 54s ⏱️
 3 832 tests  3 831 ✅ 1 💤 0 ❌
76 556 runs  76 547 ✅ 9 💤 0 ❌

Results for commit 0587de2.

♻️ This comment has been updated with latest results.

@pcanal pcanal dismissed a stale review March 23, 2025 15:29

Please tell us why you approve this request.

@hageboeck hageboeck force-pushed the root7-memoryManagement branch from 4d29c60 to 1224a4b Compare September 5, 2025 15:50
@hageboeck hageboeck force-pushed the root7-memoryManagement branch from b894456 to 167c0cc Compare November 3, 2025 10:35
@hageboeck hageboeck added the clean build Ask CI to do non-incremental build on PR label Nov 3, 2025
@hageboeck hageboeck force-pushed the root7-memoryManagement branch from 342a3cb to 0ca4f8a Compare November 5, 2025 17:34
@hageboeck hageboeck force-pushed the root7-memoryManagement branch from 0ca4f8a to 68de9c4 Compare January 14, 2026 13:23
@hageboeck hageboeck force-pushed the root7-memoryManagement branch from 68de9c4 to 9c5ce87 Compare January 21, 2026 12:53
@hageboeck hageboeck force-pushed the root7-memoryManagement branch from 9c5ce87 to b79032e Compare February 10, 2026 17:35
@hageboeck hageboeck force-pushed the root7-memoryManagement branch 2 times, most recently from 74a6279 to 8d9511a Compare February 12, 2026 16:52
@hageboeck hageboeck force-pushed the root7-memoryManagement branch 2 times, most recently from 0b52df2 to c9f787b Compare March 6, 2026 16:13
@hageboeck hageboeck force-pushed the root7-memoryManagement branch 3 times, most recently from d354941 to 3878984 Compare March 17, 2026 14:56
Replace uses of TH1::AddDirectory by TDirectory::TContext. It is
thread-local and uses the RAII idiom, so state changes cannot
inadvertently leak out of TMVA functions.
…ect.

It makes sense when a different object with the same name is registered
(the old object will leak), but if the object is identical, the
replacement is like a no-op.
In order for TTree::Draw to work as documented, histograms must be
registered to gDirectory. Therefore, make it independent of
TH1::AddDirectory and DisableImplicitObjectOwnership. Histograms will
unconditionally be registered.
- Don't rely on implicit registration to directories.
- Make the test insensitive to any defaults by always adding the
  histogram to the file.
The ROOT 7 ownership settings don't affect TH1::AddDirectoryStatus, so
objects read from a TFile associate themselves with that file.

Auto registration "off" affects whether new objects are associated to
gDirectory so the documentation needed to be updated.
TH1::AddDirectoryStatus has the same effect as before (affecting both
new objects and objects read from file), and RFile undoes or avoids any
potential registration.
When the implicit ownership is switched to ROOT 7 mode, the
corresponding notification needs to be masked from output diffs and/or
the RootTestDriver checks.
- Add Enable/DisableObjectAutoRegistration() in ROOT::Experimental.
- Add a function to test if registration is on or off.
- Allow for setting defaults using
  - The environment variable ROOT_OBJECT_AUTO_REGISTRATION
  - The rootrc variable Root.ObjectAutoRegistration
…ph2D.

In locations where TH1::AddDirectoryStatus is queried, also query
ObjectAutoRegistrationEnabled(). This extends the ROOT 7 testing mode to
TH1 and derived classes, TGraph2D and TEfficiency.
@hageboeck hageboeck force-pushed the root7-memoryManagement branch from 3878984 to 0587de2 Compare March 20, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants