Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] memory leak when recording #265

Open
1 task done
upchui opened this issue Jan 25, 2025 · 15 comments
Open
1 task done

[BUG] memory leak when recording #265

upchui opened this issue Jan 25, 2025 · 15 comments

Comments

@upchui
Copy link
Contributor

upchui commented Jan 25, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Memory leak when recording

Expected Behavior

No memory leak

Steps To Reproduce

Just record something

Environment

- OS:
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

- How docker service was installed:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

CPU architecture

x86-64

Docker creation

services:
  tvheadend:
    container_name: "tvheadend"
    environment:
      - "TZ=Europe/Berlin"
      - "PUID=99"
      - "PGID=100"
      - "UMASK=022"
    image: "lscr.io/linuxserver/tvheadend:latest"
    network_mode: "host"
    ports:
      - "9981:9981/tcp"
      - "9982:9982/tcp"
    restart: "always"
    volumes:
      - "./config:/config"
      - "/mnt/plex-dvr-temp:/recordings"

Container logs

you can't see anything about it in the logs
Copy link

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

@j0nnymoe
Copy link
Member

This needs to be reported to them, it's not going to be an issue with the container. More likely how you've configured tvheadend or the app itself.

@ldlx
Copy link

ldlx commented Jan 25, 2025

Does TVHeadend, including webinterface, stops responding at all, so you need to restart the container?

I installed my first Docker/Portainer environment on Debian 12 for TVHeadend container some days ago, am happy with live TV, but as soon as I start recording, the webinterface gets unresponsive. When there are scheduled recordings for the actual time and the recording volume is present at next reboot, the container crashes instantly.

A mounted volume has owner root:root after starting the container, but TVHeadend is running as "abc". In my logs there is "access denied" for dvr process.

@j0nnymoe
Copy link
Member

You should be creating the volumes before you deploy a container as docker will create them as root.

@upchui
Copy link
Contributor Author

upchui commented Jan 25, 2025

@ldlx it seems as though your problem is that tvheadend doesn't have the rights to write the recordings...

The web interface doesn't freeze for me, but after some time the tvheadend process consumes over 7 GB of RAM and then the OOM killer kills tvheadend.

I also tried to recreate the container with a new config. I only setup one tuner and mapped a single channel for testing to test recordings, and here, too, the memory leak is showing.

@ldlx
Copy link

ldlx commented Jan 25, 2025

added uid and gid "911" to the connect string of the CIFS volume in Portainer, which is the "abc" user inside the container. The CIFS volume is now mounted for the "abc" user and recording is working. Please excuse that I hijacked your issue.

@upchui
Copy link
Contributor Author

upchui commented Jan 25, 2025

@ldlx if it works for you now, do you also have a memory leak when you record?

@ldlx
Copy link

ldlx commented Jan 26, 2025

No, there is no memory leak (=no release of memory when recording is done), but obviously more memory is needed when recording.

Virt and Res of tvheadend preocess in TOP inside the container stay in the same range (Virt: 280000-300000, Res: 120000-135000), buff/cache has higher values during recording, but returns to lower values. And at last, free memory increases when the recording ends.

@upchui
Copy link
Contributor Author

upchui commented Jan 26, 2025

Interesting, I'll try setting up a new VM. That's the only thing I can think of that I haven't tried yet.

I'll do that in the next few days and write an update here.

@COhsrt
Copy link

COhsrt commented Jan 27, 2025

Having the same issue. Here's a screenshot of portainer. the drop happens once I stop recording.
Anyway the webinterface is responsive all the time.
The memory usage issue caused a few recordings getting crashed by OOM-Killer.

It doesn't matter if I use "pass" or "matroska"

Image

@j0nnymoe
Copy link
Member

This needs to be reported to them, it's not going to be an issue with the container. More likely how you've configured tvheadend or the app itself.

Already mentioned what needs to be done here.

@upchui
Copy link
Contributor Author

upchui commented Jan 27, 2025

Who do you mean exactly?

@j0nnymoe
Copy link
Member

We take what tvheadend publish on their GitHub and package it into a container. Any memory leaks will be at their codebase, not ours.

Though as other users here have mentioned no memory leaks, makes it seem like it's settings within tvheadend triggering it.

@ldlx
Copy link

ldlx commented Jan 27, 2025

I had two recordings that suddenly stopped last night. I started a new recording some minutes ago and can see the increasing memory usage in the stats like @COhsrt posted (I still learn to use Portainer and now I know the stats page ;-))

But: According to TOP, the application's memory is stable, but "buff/cache" is increasing. Is there a way to control the max size of the cache?
@COhsrt What is this out-of-memory (OOM)-Killer? Builtin to docker? Builtin to debian? 3rd party?

@COhsrt
Copy link

COhsrt commented Jan 28, 2025

@ldlx the kernel inbuilt oom-killer of my docker-host killed tvheadend.

And actually no. it's an issue with the container. the tv-headend process uses around 60 MB.

Image

But the container eats a lot more memory over time.

Image

what may be interesting: the recording and config files are on a nfs share and not on the docker-host itself. maybe this gives a hint on a possible issue?

An additional screenshot of the memory-usage from the docker-host

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Issues
Development

No branches or pull requests

4 participants