-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Support for weak references in frames #102960
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
Comments
Do you have a link to the results in a legible form? |
I'll get that for you tomorrow. In the mean time you can:
|
The only "Significant" one is |
There's some Deferred debugging stuff that has caused significant angst with hard references to frame objects. Weakrefs here would be hugely useful. I'm not sure exactly how we'd use them (the cycles and attendant leaks were such a problem that we have mostly given up on this sort of thing and I'd need to load the whole feature back into my head) but I definitely want this if it is a possibility! |
We have an open issue on Matplotlib due to frame related reference cycles matplotlib/matplotlib#25406 |
This is not the way to fix memory leaks. If you really must have cycles involving frames, then you can break the cycle like this: Although I have to wonder why |
|
@ambv and @markshannon , do we have plans to move forward on this? |
ping here again for whether we can have this - doesn't seem like there are a lot of downsides. The perf looks the same and the code change is trivial. pdb and bdb can use this to keep frame specific data and it can be really helpful. |
It's occasionally useful to be able to link information to active frames. Two recent examples:
Currently, since frames don't support being weakly referenced, custom lifecycle management is required in this case. That's unfortunate because errors in cleaning out the references will lead to memory leaks of dead frames and their respective locals.
The straightforward solution is to add weakref support to
frame
objects. The performance hit is limited to setting NULL on thef_weakreflist
field on frame object creation, and later a NULL check (for whether there are any weakrefs) at the frame object's deallocation. This is what the related PR does.I ran the PR and the base
main
branch at the time against pyperformance 1.0.6. The raw results are in benchmarks.zip but the gist is that there are no significant differences between the two branches in any of the benchmarks executed.Linked PRs
The text was updated successfully, but these errors were encountered: