Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed one memory leak in complex objects #537

Merged
merged 1 commit into from Jan 14, 2022

Conversation

jpivarski
Copy link
Member

There are actually two memory leaks: one is in Uproot. This one is due to the fact that ROOT instance versions can sometimes be 0 while the class version is something else, and Uproot was repeatedly redefining the class, which was both slow and contributed to global memory (because they're new classes). The commit in this PR fixes that (checks for instance version 0 and no matching known_version, tries maximum known_version instead).

The other memory leak is in NumPy: numpy/numpy#6581 (comment)

If you follow the thread back, people have been talking about it since 2009 (SciPy ticket 1003, ported to GitHub in 2012, superceded by the above issue in 2015, and there's an open PR numpy/numpy#15065, last touched in 2021).

We have NumPy object arrays with cyclic dependencies because (at least) STLVector and friends have NumPy values, which can sometimes be objects (because it's ROOT data), and those objects can point to themselves through _parent. I don't like the idea of the STL collections sometimes being NumPy (when they're numbers) and sometimes not (when they're objects), and a quick attempt at implementation led to instant test failures, so no. Too many design decisions were based on the idea that a NumPy object array is just a fancy Python list (including not having memory leaks, like a Python list). Maybe some of these objects don't need to have _parent? What about cyclic references through the Cursor's refs? Either way, it's getting messy quick.

Of course, if NumPy's bug gets fixed, no changes would be needed in Uproot. Ideally, that's what ought to happen.

@jpivarski jpivarski linked an issue Jan 14, 2022 that may be closed by this pull request
@jpivarski jpivarski enabled auto-merge (squash) January 14, 2022 02:54
@jpivarski jpivarski merged commit 885ecb2 into main Jan 14, 2022
@jpivarski jpivarski deleted the jpivarski/memory-leak-for-complex-objects branch January 14, 2022 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak in iterate function
1 participant