-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
BUG: Fix memory leak for subclass slicing #10068
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
Conversation
Careless on my part in #8953 |
I really do not get why the error paths end up with one extra reference to that object, even happens if I call |
@mhvk, If it causes a noticeable problem, as this seems to do, there is no reason not to backport. I'm going to do a 1.13.4 about the same time as 1.14.0 just for the distros who are still on 1.13. |
Too sleepy to figure out why the error paths have a higher ref count. Probably can just rip that part out of the test, or put a 3 until someone gets 2. It did decrease by one correctly of course.... |
|
Thanks for the fast reaction! The fix looks good, not sure about the refcount in the test either. When I run the same code as a standalone script, I get
Why was it added back in the first place? To support user code that called
No, I just checked that |
Yes, it is just to support For subclasses, the automatic wrappers will create the C-side slot if they find |
I guess I will remove the test probably. the refcount is bad for any method (and inheriting only object, and moving the def to top level). Also it works correctly on my python 3. I would not be too surprised if it is already fixed in python 2 master as well. It still seems strange to me, I can't see why this is not a moderately bad memory leak in python 2. |
Ah, found it with a bit of googleing. Something leaks into the exception info. So it collected when a new exception gets raised. |
One strategy for making refleak tests more robust is to call the function, like, 100 times in a loop, and then assert that the refcount is less than 50. |
Hehe, yeah, we are over engineering here a lot already anyway ;). It
won't work here tough, the object being leaked is recreated every time.
|
Interesting. So can you fix the test by manually raising and catching an exception before checking the refcount? It may also be possible to run |
So a refcount of 2 should be OK? It would be good to finish this up, I'd even take the fix separate from the test if that will speed things up. |
Sorry, am overloaded. Tests should pass now |
They do! They trigger a
So in addition, you will need a |
You can't win ;) Now Python 2.7 with the I'll be glad when we can drop 2.7. |
A slice object was created if __getslice__/__setslice__ was used by an inherited subclass (through python or directly) but not decref'd. Closes numpygh-10066
Yeah, yeah, I am getting there, heh.... |
Thanks Sebastian. |
Thank you for the quick fix and your perseverance :) |
A slice object was created if getslice/setslice was used
by an inherited subclass (through python or directly) but not
decref'd.
Closes gh-10066
--
I admit, I probably overdid it on that test, heh.