Frigate causing memory leak until restart

I have only recently installed and configured Frigate and since the outset, I seem to be having a memory leak. After the add-on is started it will creep up until HA becomes unresponsive. I’m guessing the Supervisor then restarts HA after which everything is fine until the memory creeps up again, then rinse and repeat.

I am running HomeAssistantOS in VirtualBox with 1 CPU and 6GB of RAM. When I first installed Frigate it had 4GB RAM but I saw some references to the VM needing more RAM so I increased to 6GB. But this just prolonged the stay of execution.

It seems to definately be Frigate causing this issue as when I stop the add-on the memory returns to normal. I currently have Blue Iris as my NVR with Amazon Rekognition for object recognition but I really want to move this over to Frigate if I can!

I have only added one camera to Frigate so far for testing (but have another four to add):

mqtt:
  host: <ip>
  user: mqtt
  password: <pw>

cameras:
  driveway_cam:
    ffmpeg:
      inputs:
        - path: <url>
          roles: 
            - detect
            - clips
    detect:
      width: 1920
      height: 1080
      fps: 5
    objects:
      track:
        - person
        - dog
        - car
    snapshots:
      enabled: True
      timestamp: True
      bounding_box: true
      retain: 
        default: 3

detectors: 
  cpu1:
    type: cpu

Things I have tried so far:

  • Increasing VM Memory from 4GB to 6GB
  • Changing FPS in Frigate config from 25 to 5

Any ideas are appreciated. Thanks for reading.

Need more information to see what is actually using the memory. We have seen this rarely with users using vaapi for hwaccel on certain intel devices but it does not seem you are using hwaccel.

That being said, it looks like your config is somewhat out of date. For example the clips roles does not exist anymore.

I’d also suggest checking frigate logs

Thanks for the prompt reply.

Quite right on the out-of-date config, I added the clips based on a blog for configuring it. I have just removed it and restarted the add-on.

Here are the logs since I have just restarted:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[2023-02-27 21:26:27] frigate.app                    INFO    : Starting Frigate (0.11.1-2eada21)
[2023-02-27 21:26:27] frigate.app                    INFO    : Creating directory: /tmp/cache
Starting migrations
[2023-02-27 21:26:27] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2023-02-27 21:26:27] peewee_migrate                 INFO    : There is nothing to migrate
[2023-02-27 21:26:27] frigate.mqtt                   INFO    : Turning on recordings for driveway_cam via mqtt
[2023-02-27 21:26:27] detector.cpu1                  INFO    : Starting detection process: 210
[2023-02-27 21:26:27] frigate.app                    INFO    : Output process started: 212
[2023-02-27 21:26:27] frigate.app                    INFO    : Camera processor started for driveway_cam: 214
[2023-02-27 21:26:27] ws4py                          INFO    : Using epoll
[2023-02-27 21:26:27] frigate.app                    INFO    : Capture process started for driveway_cam: 217
[2023-02-27 21:26:27] frigate.edgetpu                WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
[2023-02-27 21:26:28] ws4py                          INFO    : Using epoll
[2023-02-27 21:26:34] ws4py                          INFO    : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:35190]
[2023-02-27 21:26:35] ws4py                          INFO    : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:35190]

When I have reviewed the logs before the only thing of note I have seen is multiple ‘Manager websocket’ and ‘Terminating websocket’ which I gather is normal behavior. What is interesting is that since the last ‘Terminating websocket’ in the log above the Memory usage has continued to rise even though nothing has been added to the Frigate logs (~2.3GB to ~3.2GB)…

You should use the CLI to run top inside the container. No way to know what is using the memory otherwise.

That, or you could try updating to frigate beta which has a lot more statistical information about cpu and memory usage for each process built into the UI (among many other things, be sure to read the change log first if you update)

I have updated Frigate to the Beta version and instantly saw a difference in the memory utilisation:

I stopped the GA Frigate version just before 08:00 and started the Beta version. I guess whatever was causing the memory leak for me is not present in the Beta version.

I guess I will continue to test with the Beta version but at least initially it seems positive!

Thanks for your help.

1 Like