-
Notifications
You must be signed in to change notification settings - Fork 29
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 during import #90
Comments
Why did you import aiofile in a function? I just finished to test it with taskiq's worker and do not see a memory leak because of aiofile, memory usage is not changing. |
I didn't import it in a function. I launched a script several times, imported aiofile inside of it. It's just an example |
I meant why did you write the code like: # liveness_probe/__main__.py
import asyncio
async def liveness_probe() -> None:
import aiofile
aiofile but not like: # liveness_probe/__main__.py
import asyncio
import aiofile
async def liveness_probe() -> None:
aiofile Also, are you seeing the memory leak in K8S only? Can you make a test script without K8S? |
Got it. You're right, that would be more correct. # liveness_probe/__main__.py
import asyncio
import aiofile
async def liveness_probe() -> None:
aiofile And that's how we use it on our side. But this script is loaded dynamically and executed, so every time we run it, we import aiofile again. Additionally, memory leak is confirmed with memray. |
Can you attach the memray log? I also tried to check this issue with memray, but haven't found the leak. |
Long story short
I use aiofile to check health of consumers. Some file is being touched during consumer process and then in k8s liveness probe I compare modified time.
Unfortunately I noticed a memory leak that was caused by liveness probe.
Expected behavior
I expect no memory leaks :)
Actual behavior
There is one.
Steps to reproduce
Here code for reproduction:
Aiofile should be imported inside function.
Just probe inside k8s Deployment.
Environment info
k8s version: 1.21.8
aiofile version: 3.8.0 - 3.8.8 (didn't check other)
python version: 3.11.3 - 3.11.6 (didn't check other)
I have been produced this problem with implementations:
✅ export CAIO_IMPL=linux
✅ export CAIO_IMPL=thread
✅ export CAIO_IMPL=python
Additional info
Here are graphs of the increase in the amount of memory consumed in pod:
The text was updated successfully, but these errors were encountered: