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
memory leak in PyEval_EvalCodeEx #90505
Comments
I'm investigating a memory leak in 3.10, and while looking at the offending commit I stumbled upon this: in ceval.c:PyEval_EvalCodeEx, there's this allocation: PyObject **kwargs = PyMem_Malloc(sizeof(PyObject *)*kwcount); The problem is that this isn't ever freed. And |
(this is the context of our current investigation btw: MagicStack/asyncpg#874 (comment)) |
This is the questionable place in the code: Lines 6131 to 6166 in dce642f
See that |
I can confirm that removing the kwargs allocation prevents the leak described in the asyncpg issue from happening. |
Turns out this leak affects CYthon quite a lot: This seems to imply that every function call using __Pyx_PyCFunction_FastCall is leaking memory in 3.10, which is quite bad. We may need an urgent release for this :( |
The function will still leak "kwnames" and "default" if creating the "func" object fails. Admittedly that would only happen in a low-memory condition which is a) rare and b) probably only happens just before the interpreter completely dies, so it's not worth addressing during today's mild emergency. |
(Sorry--it'll leak "kwnames", "newargs", and "defaults".) |
Apparently, this is causing adyncpg to leak megabytes in seconds |
The memory leak has been fixed in 3.10 and main branches. Can this issue be closed now? |
Yeah, here's another PR to address that: #30551 |
when was the regression introduced? I wouldn't necessarily rush an urgent release out unless this was just introduced in the 3.10.1 patch release. Could it wait for 3.10.2 already scheduled for four weeks from now? |
The leak was introduced in 3.10a5 (0332e56) |
I don't feel comfortable leaving a ton of Cython functions leaking memory constantly on many function calls. According to MagicStack/asyncpg#874 asyncpg can leak quite a lot of memory depending on your usage pattern. Even if this is the first time we heard about this problem, I think this is important enough to justify a extra release. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: