JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
947 stars 80 forks source link

RAM leak #601

Closed Anth0ny29 closed 2 weeks ago

Anth0ny29 commented 1 month ago

Description

Hello!

I've noticed that RAM usage on my RPi3b+ keeps increasing when using the TAPO integration for my C200 camera. I recently switched to a NUC thinking my Raspberry Pi was the problem, but the issue persists.

In the provided screenshot, the available RAM gradually decreases until it either causes my Raspberry Pi to restart or completely crash. After disabling the integration, the problem seems to have disappeared.

Is this a known issue?

I don't have any specific errors, except for some camera sensors taking more than 10 seconds to update.

Screenshot_20240531-091009

Reproduction Steps

1 - Integrate C200 Tapo Camera with the integration 2 - Wait a few hours and see if the RAM usage goes up

Expected behavior

No RAM leak

If applicable, add error logs.

No response

Device Firmware

1.3.13 Build 240327 Rel.63336n(4555)

Integration Version

5.4.13

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

RPI 3B+ and NUC

Search for similar issues

Yes

Additional information

No response

JurajNyiri commented 1 month ago

Could you try disabling most of the features under integration options? Onvif, time sync etc to see if we can identify the area causing the leak.

JurajNyiri commented 1 month ago

IMG_1393

I can see something similar on my system as well but I have not verified whether it’s caused by this integration or not.

JurajNyiri commented 1 month ago

As a first step please keep it off for a longer period to definitely conclude it is caused by this integration as in your screenshot the without Tapo part is very short.

Anth0ny29 commented 1 month ago

I will disable the integration for a longer period, and I will get back to you when I have more information! I wanted to at least bring up the topic for investigation :)

JurajNyiri commented 1 month ago

Thank you for that! I will try to investigate code in the meantime to see if I can find anything. If you find it is caused by Tapo, under configuration for the device under settings:

if the problem stops, start enabling again If the problem does not stop, I know which areas are not causing the leak at least.

Memory leaks are very hard to track down usually.

Anth0ny29 commented 1 month ago

Small Update: I left most of the day without the Tapo integration (until I launched a RAM profiler which crashed everything) and apparently the RAM continues to gradually increase. It does seem slower though, which might be why I thought it was caused by the plugin. So, I don't know if this is normal or not, and whether it's actually a problem in the end. Maybe everyone experiences this but after a while it goes down on its own (and my RPI3B+ was just limited with 1GB of RAM). Tapo disabled

JurajNyiri commented 2 weeks ago

Hi @Anth0ny29 any luck in here? Can we close this or is this an issue?

Anth0ny29 commented 2 weeks ago

Hello! I wanted to wait and see in the long run, but apparently the RAM usage increases and then seems to stabilize after a while. Maybe my Raspberry Pi lacked RAM and the NUC can handle the RAM demand over the long term. I think we can close the topic. Anyway, thanks for looking into it :)

image