Skip to content
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 with Python 3.11.2 and Debian Bookworm on RPI with HASS Core installation #311

Open
altserg opened this issue Oct 30, 2023 · 2 comments

Comments

@altserg
Copy link

altserg commented Oct 30, 2023

Hi all,

I'm using HASS Core on RPI, and I'm moving to the latest Debian OS version.
I have noticed that with Python 3.11.2 (also with Python 3.11 manually compiled on previous RPI OS version), the memory usage raises very quickly when Dahua integration is enabled. Refer to attached memory usage log with peaks at the end corresponding to enablement of Dahua integration and HASS restart

image

I'm wondering if anyone else has noticed something similar, and I would appreciate any help in debugging the issue - how to track all memory allocations in Dahua component ? Or maybe it's something with asyncio that goes wrong ?

@altserg
Copy link
Author

altserg commented Oct 31, 2023

Looks like the issue is related to aio-libs/aiohttp#7252
Flag enable_cleanup_closed=True in iohttp.TCPConnector.
When I removed the flag in init.py, the memory consumption is not increasing so rapidly. I'm testing now, will report the result.
However, if this works, should some Python version check and quick be implemented in init.py ?
Note that in the linked issue people are saying that the fix should be implemented in Python 3.11.4, I had the memory leak in self-compiled later Python 3.11 versions. Debian bookworm has Python 3.11.2, so the quirk has to be implemented there anyway.
This is what HASS implements
aiohttp_client.py:ENABLE_CLEANUP_CLOSED = not (3, 11, 1) <= sys.version_info < (3, 11, 4)
aiohttp_client.py: enable_cleanup_closed=ENABLE_CLEANUP_CLOSED,

@altserg altserg changed the title Possible memory leak with Python 3.11 and Debian Bookworkm on RPI with HASS Core installation Possible memory leak with Python 3.11.2 and Debian Bookworkm on RPI with HASS Core installation Oct 31, 2023
@altserg altserg changed the title Possible memory leak with Python 3.11.2 and Debian Bookworkm on RPI with HASS Core installation Possible memory leak with Python 3.11.2 and Debian Bookworm on RPI with HASS Core installation Oct 31, 2023
@altserg
Copy link
Author

altserg commented Oct 31, 2023

So far so good with enable_cleanup_closed=False
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant