doitandbedone / ispyagentdvr-docker

GNU General Public License v3.0
113 stars 44 forks source link

Memory leak #690

Closed syllith closed 3 months ago

syllith commented 4 months ago

Affected Version v5.3.2.0

Describe the bug Over the course of 1 hour, Agent DVR will steadily and consistently increase the amount of RAM used until it consumes 100% of my available memory (128 GB). Restarting the docker container will free the memory and reset this process

Steps To Reproduce I installed a fresh copy of Arch Linux along with docker compose. the following is the docker compose configuring for Agent DVR:

agentdvr:
    container_name: ispyagentdvr
    image: doitandbedone/ispyagentdvr:latest
    volumes:
      - /hdd/docker/agentdvr/config:/agent/Media/XML/
      - /hdd/docker/agentdvr/media:/agent/Media/WebServerRoot/Media/
      - /hdd/docker/agentdvr/commands:/agent/Commands/
    ports:
      - "8090:8090"
      - "3478:3478/udp"
      - "50000-50010:50000-50010/udp"
    environment:
      - TZ=America/Chicago
    restart: unless-stopped

My new Arch install is running via a 500 GB NVME. I have a 36 TB HDD as well that I would like the docker data to be stored to, due to space restraints on the NVME. I managed to do this by modifying the /etc/docker/daemon.conf file to look like this:

{
  "runtimes": {
    "nvidia": {
      "path": "nvidia-container-runtime",
      "runtimeArgs": []
    }
  },
  "default-runtime": "nvidia",
  "data-root": "/hdd/docker/data-root"
}

As you can see, the above reconfigures the data-root to be stored in the /hdd/docker/data-root directory. /hdd is where I have the hdd mounted to.

Expected behavior On my previous Arch install, Agent DVR had no problems. The only difference between this setup and my old one is the fact that I didn't change the data-root directory, but none of my other containers are experiencing problems and I feel like this should work as intended.

Reproduction rate 100% of the time

Screenshots The following screenshot shows my RAM usage from the last 24 hours. Although this may look like its clearing itself, this is actually due to me manually resetting the docker container every hour or so. If left unchecked, it will continue t o use 100% of my RAM. Looking at the TOP command, I can see that Agent DVR is the one responsible for using all this memory image

Host System Information (where ispy agent is running/hosted):

    Model: HP ProLiant DL380 G9
    Memory: 128GB DDR4 ECC RAM
    CPU: 2x Intel Xeon E5-2680 v3 (48 @ 3.300 GHz)
    GPU: Nvidia GeForce GTX 1080 Ti
    Storage:
        HDD: 12x4 TB HDD (RAID 50)
        NVME: 500 GB
    Power Supply: 2x 800 Watt
    OS: Arch Linux

Client System Information (device accessing the web portal, if applicable): This memory usage will increase regardless if you are actively watching the stream in a browser window or not.

Additional Information The configuration I am using for Agent DVR is one I backed up from my previous setup, which didn't have any memory leak problems.

ispysoftware commented 3 months ago

need to check the logs at /logs.html - set logging level in server settings - logging

syllith commented 3 months ago

Ok, I have enabled debug logging and from what I can tell, everything looks pretty normal:

logs(1).txt

At one point, I tried trace logging with ffmpeg, and this was spamming the console quite often:

FFmpeg: error: [mjpeg @ 0x70e73000e0c0] unable to decode APP fields: Invalid data found when processing input

I am not sure if this has anything to do with it. In the first half of the log, I had ffmpeg logging enabled, then turned it off halfway so you can see both sets of data.

syllith commented 3 months ago

I may have fixed the problem. I completely removed and repulled the docker image and did NOT use my old configuration. Instead I manually reimported all my cameras fresh and it appears the problem has now been resolved. I can now see the memory being cleared out periodically and I am under 1 GB of usage, even after running for several hours