-
Notifications
You must be signed in to change notification settings - Fork 40
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
Possible memory leak in Python 3.11.0 #98
Comments
@juanfem Have you run the unittest suite? This includes some tests intended to detect some kinds of problems with reference counting. Also, do your tests for py3.10 vs. 3.11 use the same version of Cython? |
Also, P4P includes some tools for detecting and troubleshooting resource leaks. from p4p.disect import periodic
periodic(period=10.0, file=sys.stderr) Will periodically print information about changes in the number of objects of various types. eg.
Some kinds of resource leaks manifest as a consistently positive "delta". Another, less well developed, tool is |
Only one test fails, but it seems to be an unrelated error:
This error is related to I installed p4p using pip and I don't have Cython installed. Should I have it? |
Ah, I must have missed that one w/ #82.
Agreed. This probably rules out a simple ref. counting omission in either hand written or cython generated c/c++ code. At this point I suspect a resource leak through some container growing without bound. I think that running the Also, do you see any error, warning, unusual, or simply different messages being logged? (I would strongly recommend to always enable |
I have easy access to podman, not docker. I can install P4P in an instance of Calling I modified
|
Interesting, the main difference in your setup is the Python version. I am using 3.11.0, which is the latest available in conda, and you used 3.11.1. I just ran the tests on one of the Python official Docker images with 3.11.1 as you did and the leak is gone. It seems the memory leak only affects 3.11.0. I suspect the leak was related to this bug that was fixed in 3.11.1. |
By the way, yesterday I also tested |
A leak on GIL lock/unlock would certainly explain what you do and don't observe. I guess 3.10.0 has to be considered unusable for long running processes? Absent further input, I will consider this issue closed as "not my bug" :) Thanks for taking the time to test and report. |
I know that Python 3.11 is not yet fully supported, but I think this is something you should have a look (or prevent people from using p4p on py3.11)
I found a memory leak in one of my codes after upgrading to Python 3.11, and I finally traced it to p4p (or pvxs). It seems there have been some changes in the C API and Google reveals that more libraries are affected...
To reproduce it, you just need to create a PV monitor and you'll see how memory is leaked at every update.
I tried both the thread and asyncio clients with the same outcome. See plots below.
Python 3.11:
Python 3.10:
I am also attaching some files to reproduce the issue on Docker:
p4p_mem_leak_test.zip
To run it, first build the image with:
Then start a soft IOC with
To test the asyncio client:
And to test the thread client:
You can also run the python scripts locally if you prefer.
To test on Python 3.10, just change the version in the
environment.yml
file and build the Docker image again.The text was updated successfully, but these errors were encountered: