Memory leak

YES! I’ve been experiencing this same problem for the last couple of weeks. The memory use builds to around 90%, the load suddenly goes from around 0.2 to between 30 and 60 and the whole system becomes unresponsive.
I’ve been disabling random things, but haven’t isolated the issue yet.

I started experiencing these problems not long after changing over to use MySQL instead of the default SQLite, and booting from SSD, so I was wondering if was related to one of those.
I don’t think I made any other changes around the time that the problems started.

I had memory issues with speedtest integration. Someone using it here?

No, not me.

I also have problems and I have integrated Speedtest. Now deactivated and no improvement. However, several integrations may be affected.

After a few tests I have to change my statement. I think for a very large part of the memory growth was due to the modul “speedtest”.

@phaeton How’s your HA running now? I saw you said it had been running ok for a day.

I restored the backup including the first option: 0.112.x. This didn’t work. The same issues. I moved over to installing Proxmox yesterday(which was on muy list anyway), creating a virtual machine and restoring only the files and settings. This did work for for now. No problems anymore since 23 hours. This is longest uptime since weeks. I think something went wrong along the way with my install and the reinstall fixed it. I doubt the stability has to do with Proxmox, but since I wanted Proxmox any way I installed it.

Hmm. Thanks for the info. I’m pretty sure my problem is the same as yours. I’m not sure why they deleted my comments on your Github issue.
Today I switched back from MySQL to SQLite, but I’m still seeing the issue.
I might try restoring an older backup next.

1 Like

Do you have spotcast enabled?

Please see 0.113: Automations & Scripts, and even more performance!

I’m still having problems with memory use steadily increasing. I have to restart Home Assistant every day or two to get the memory and the load back down.

If you setup some code to log every few seconds with objgraph, most leaks can be discovered:

        _LOGGER.debug("Most common types: %s", objgraph.most_common_types(limit=25))
        _LOGGER.debug("Growth: %s", objgraph.growth(limit=25))

https://mg.pov.lt/objgraph/objgraph.html

I’ve just seen this. Thanks. I’ll have to give that a go.

Has anyone else here resolved their memory leak issues?

Starting in 0.118 (releasing today)

You can use the profiler.start_log_objects service to log the growth of new objects in memory.

Then you can use the profiler.dump_log_objects service to dump the ones to the log that are unexpectedly growing.

Finally once you have found the leak, call the profiler.stop_log_objects service to disable logging.

1 Like

I get “Failed to call service profiler/start_log_objects. Service not found.” when I try to call that service from Deleloper Tools. Is there a different way I should be doing it?

Which version are you using?

Can you elaborate on how to use the dump log objects. I get required key not provided? I looked at the docs and it says it’s required to put a type but I’m just trying to figure out what would be useful to put to track a memory leak issue I’m having.

Once you have found the type of object that is leaking you need to provide the type to the service call.

For example

type: State

I didn’t manage to make sense of the profiler, but it seems to me that the problem is related to the front end. If I click through click around the UI a lot, particularly into the sensor graphs, then Home Assistant eventually runs out of memory. If I don’t view the detail of graphs it can surivive without having to be restarted daily. I guess the data from those sensors is building up in memory or something.

Hi,

I am really trying to make sense of this ;-). I do get the profiler to put things in the log, I do understand (grammatically) what you say about identifying the type of object and then having to dump that type of object, finding out the type of object however is a bit misty to me.

If, for instance, I have the following popping up:
"[homeassistant.components.profiler] Memory Growth: [('function', 91217, 2), ('DNSService', 28, 1)]"
in the logfile, is the type then “function”, “DNSService” or something else?

I am trying to get my finger behind something which is leaking memory like crazy resulting in the swap file filling up quite rapidly and HA getting very sluggish. (running HASSOS 5.13 on Odroid-N2+ (“blue”)). As an interim solution I have set up an automation which just reboots the host once swap gets to 40% or so (at which point sluggishness starts to appear).

Any insights, directions etc. much appreciated.

Cheers,
F.

1 Like

function is a generic python function

DNSService is likely a zeroconf object

OK thanks. I will keep digging and see what I find.