Page 2 of 3
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Tuesday 26 March 2024 14:21
by Kedi
Your picture is not visible. Everybody should use pictures from the widget Process Usage
Because that is the memory consumption from Domoticz
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Tuesday 26 March 2024 16:01
by waltervl
Does your dzvents scripts use shellcommand or OpenURL?
When not closed correctly these external resources can stay open....
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Tuesday 26 March 2024 16:35
by Kedi
When you use shell commands in Linux and they are not properly closed they become zombies or you should see them when you do a 'ps aux'
I have seen none of those.
You can find zombie process by
If openURL is calling an external program (curl or a like) then the same applies.
If it is done internally, Domoticz should take care of close properly.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Saturday 30 March 2024 12:10
by niki_lauda
I am glad that a few have experienced the same problem.
I have phenomenon since the last few months. 2024.4 also run Mqtt and dzevents
Disabling dzevents for now. Will come back with the results
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Saturday 30 March 2024 14:50
by Kedi
Last updates to the dzVents system are from 2 months ago.
If your memory rise is from after that time, then 1 of your scripts added or changed the last 2 months could be the cause.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Saturday 30 March 2024 21:06
by niki_lauda
niki_lauda wrote: ↑Saturday 30 March 2024 12:10
I am glad that a few have experienced the same problem.
I have phenomenon since the last few months. 2024.4 also run Mqtt and dzevents
Disabling dzevents for now. Will come back with the results
Dzevents is not the problem. Memory usage increased with dzevents switched off
Last night briefly disabling admqtt clearly had a positive effect on memory.
Memory usage went down from 128mb to 49 mb.
Can anyone else test this?
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Sunday 31 March 2024 11:01
by Kedi
If I disable MQTT-AD on my RPi-4b test system (some 400 devices), the process usage stays the same.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Tuesday 02 April 2024 9:13
by ajongen70
I have disabled the Motherboard Sensors Hardware for a few days now and monitoring the Memory usage of Domoticz with Monit shows a stable usage.
Hypothesis: the Motherboard Sensor Hardware creates a memory leak.
Is there anyway to confirm this? Who is maintaining the Motherboard Sensors code?
PS: I do not have MQTT Auto Discovery Gateway enabled. I do have the MQTT Gateway (without AD) enabled.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Tuesday 02 April 2024 9:28
by Kedi
That is NOT the case. I have several systems on RPI's. On every system I have Motherboard sensors enabled.
I have an RPi's (Remote slave) which does NOT suffer from a memory leak.
My 'master' system suffers from a memory leak. Both run the same OS version.
My test system with an other OS does not suffer from memory leak.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Wednesday 03 April 2024 20:57
by waltervl
On my test system running latest beta I only see memory leaks of approx 30MB per day if I use python event scripts (not plugins). This is already a long time known bug
https://github.com/domoticz/domoticz/issues/5091
I have several dzvents scripts running, some python plugins and some native integrations. This all works stable on my test system until I enable python event scripts.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Thursday 04 April 2024 9:24
by Kedi
I don't have any Python event scripts running on my systems.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Thursday 04 April 2024 18:58
by waltervl
And I don't have MQTT AD....
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Saturday 13 April 2024 9:25
by JanVlietland
I ran various tests last week. In my case, the more sensors I enable, the more memory leaks occur. Disabling all scripts does not make a difference. Additionally, the type of hardware (MQTT, Gateway USB, Gateway LAN) does not affect the issue. Disabling MQTT slows down the memory leak the most since it connects to about 700 devices.
I plan to run a second PI with a backup from August 2023, but I haven't found the time yet. Restarting daily at 3:30 AM is a workable workaround for my setup.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Wednesday 24 April 2024 8:51
by gizmocuz
There are NO memory leaks in MQTT(-AD)...
But the more devices you have, the more memory it uses. This is logical and throughout the whole system.
All device configuration is stored for example, which takes a bit of memory.
Memory is not an issue these days.
There seems to be a known leak when using Python scripts. This has been there since quite some time.
As I don't use Python plugins (except one), and have limited knowledge of side loading this (and wish to stay that way),
this is not a priority for me to solve and I hope other will do so. As already have been tried a few times.
Also 40 MB memory increase is nothing.
Most systems these days have 2-4GB memory. If you run on a system with 100mb of memory I suggest upgrading this.
I have systems running MQTT for months without memory issues.
There are also other forum posts related to memory leaks as well as on Github, and no need to start another one.
And before 'just saying' the memory should come from 'this and that' hardware, I suggest having a look at the code to actually support this nonsense.
Show me the malloc's and new's and other dangerous memory allocations being used (if at all) without being freed.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Wednesday 24 April 2024 8:55
by waltervl
gizmocuz wrote: ↑Wednesday 24 April 2024 8:51
There seems to be a known leak when using Python scripts. This has been there since quite some time.
As I don't use Python plugins (except one), and have limited knowledge of side loading this (and wish to stay that way),
this is not a priority for me to solve and I hope other will do so. As already have been tried a few times.
There is an issue with Python Event scripts (on Linux, not windows) as you mention, not with Python Plugins.
https://github.com/domoticz/domoticz/issues/5091
I am still able to reproduce this. But I do not use Python Event scripts but dzvents
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Wednesday 24 April 2024 8:56
by gizmocuz
Yes there are memory issues throughout the whole Python implementation.
This includes both events and certainly plugins.
There are even example python plugins made and posted on Github that proves this.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Wednesday 24 April 2024 9:59
by lost
gizmocuz wrote: ↑Wednesday 24 April 2024 8:51
Most systems these days have 2-4GB memory. If you run on a system with 100mb of memory I suggest upgrading this.
I have systems running MQTT for months without memory issues.
Well, that's my current uptime even if, this time, Domoticz was indeed restarted on January upgrade (otherwise, this would not have been done):
Code: Select all
uptime
09:27:52 up 226 days, 17:55, 1 user, load average: 0.07, 0.07, 0.05
cat /proc/meminfo | grep -i avail
MemAvailable: 482620 kB
So more than 7 months uptime for whole system and almost 3 months without domoticz restart: So that's for sure stable!
I use a PI3B with 1GB, so ~50% used. When I started with Domoticz at the end of 2016 this was 10% but since then I added some IP cams processing (custom service running aside Domoticz) that use some tmpfs in ram to minimize uSD use/wear. So most increase is inked to this.
Only one python plugin (zigbee4domoticz but only 3 zigbee devices compares to 10's zwave) that did not changed figures.
I have 3 python based services (not plugins) for cams/presence-detection/fixed-phone spammers filtering that are only linked to Domoticz using http/json API or generating/feeding custom pages. So out of plugin system that was a bit new at the time, but can observe after restarting the most hungry one
(managing cams) after some changes/additions, memory use drops immediately for ~10% then steadily rise for 6/8 hours and then remains stable to current ~50% use.
So python garbage collector looks very-very long to kick-in, even on a sane system running like a Swiss clock... Probably not very helpful mem management behavior to understand a leak RC that may have taken place hours before. And maybe misleading people that panic before the kind of python interpreter dirty ratio is reached? Don't know if this can be tuned.
Anyway, Domoticz can still run on a system with a few 100's MB with a few care (minimal Linux system/No DE needed if headless...) IMO. 1GB is still large even with some side video/image (basic) processing.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Tuesday 30 April 2024 8:55
by JanVlietland
An update that hopefully shines some light on the matter:
I have extracted the Domoticz dir from the backup (dd -> disk image) of july 2023 (2023.2) and installed that version on the RPI and manually copy pasted all scripts.
Result: no memory leak.
Then updated Domoticz to the latest version (2024.4), via the Domoticz site.
Result: no memory leak.
Then installed the latest version of domoticz (with curl) and imported the database.
Result: memory leak
My conclusion is that my Domoticz database causes the issue. So for me problem solved. Hopefully the above will help others to find the root-cause.
ps: I noticed with the clean installs that MQTT and Mysensors autodiscovery is not working if lots of devices are used. But that's another story and will post in that thread.
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Tuesday 30 April 2024 10:46
by Kedi
JanVlietland wrote: ↑Tuesday 30 April 2024 8:55
My conclusion is that my Domoticz database causes the issue. So for me problem solved. Hopefully the above will help others to find the root-cause.
I don't understand your conclusion. How can the database be the cause, and how did you solve the problem?
Re: Domoticz Memory leak in 2024 beta build 15910
Posted: Wednesday 01 May 2024 12:03
by JanVlietland
With a clean install and importing the data created memory leaks, while the present install with an older version of the database got rid of the memory leak.
Have you tried to export the database, mv domoticz domoticz.bak, reinstall with curl and then imported an older version of your database?