Out of memory!@!

Just wanted to share my frustration. Out of nowhere, my HA alerts me that it cannot make backups because of memory allocation. I could not figure out how to fix. Finally I was able to make a full backup, reinstall HA and upload the backup. ALL FIXED!!! Apparently something was making the backups in the 600MB range…once I reinstalled, the BU is below 60M. WOW…and what a relief. Hope this helps someone else.

Rookie numbers. My backups are 3.7GB.

Is it though?

You did not change anything and you restored the system to exactly what it was before. Very possibly a host reboot (not a home assistant restart) would have done the same thing.

My guess is whatever is leaking memory will continue to do so and you will have trouble again in future.

Install this integration and keep an eye on the system resources:

1 Like

I agree the problem isn’t fixed. Since it was the backup size which was bloated, something must be taking up a lot more storage on your system. First thing to check is your recorder database file, and any media files you might have. You can exclude media files from the backup if that’s the problem. Then review your add-ons to see if any of them store data.

Gentlemen…I believe you are correct. The backup is slowly getting larger. What would your recommendation be to figure out why it continues to grow even though I’ve not added anything and they are full backups. I understand that more info would need to be shared, but I don’t know where to start. I did install the suggested System monitor. Thanks in advance,

You could download two backups open them and compare them.

You need to identify the chatty entities which are spamming the database, and exclude them in configuration.yaml (or find a way to make them less chatty.) There’s a lot of information on how to do that, including this link: How to reduce your database size and extend the life of your SD card

Also consider your purge_keep_days. With long- and short-term statistics now available, you might be able to get by keeping the “live” data for fewer days.

If you really want to find out what the problem entities are, the easiest way is to install something like DB Browser and open a copy of the database. There are a number of posts suggesting some good SQL statements to try, but be aware that the database has changed a bit over the past year or so. Here’s one to get you started:

SELECT
    sm.entity_id,
    COUNT(*) AS row_count
FROM states AS s
JOIN states_meta AS sm
  ON s.metadata_id = sm.metadata_id
GROUP BY sm.entity_id
ORDER BY row_count DESC;

Also take a look at your statistics table. You might decide you don’t need all those data kept forever as long-term statistics.

Remember that every time you add a device, HA is going to record every state change for whatever keep_days you specified, and possibly keep some LTS, too. That would be a good time to review the entities created and add any you don’t need to keep to the Recorder exclude list.

For example, you just added the System Monitor integration. Do you know how frequently it updates? Do you know how many entities it’s updating each time? Which ones do you really need to keep a history of?

My go-to for figuring out exactly what’s causing database growth, is to install and use the “DbStats” addon --which is mentioned as suggestion #1 in the “How to reduce your database size…” article.

1 Like