pdulvp / jellyfin-qnap

Jellyfin server packaging for QNAP NAS
https://jellyfin.org
519 stars 33 forks source link

High memory usage #95

Open tusquitoni opened 3 months ago

tusquitoni commented 3 months ago

Hello,

I have installed this Jellyfin on my Qnap NAS with 32 GB RAM and I have a really bad RAM consumption problem. When Jellyfin is active, without doing any work, it consumes almost 50% of the RAM. But just by scanning a library I get even more consumption, reaching to saturate the NAS completely as it reaches 99% of RAM consumption. This causes the NAS to stop the process to protect itself.

I know that Jellyfin consumes a lot of RAM being a .Net application, but in my case I can not use it because it directly saturates the NAS and stops working. Does it happen to anyone else? Thank you.

Best regards.

Oednerich commented 3 months ago

Hey there,

can you tell me a bit more about your whole setup? NAS Model, CPU, QTS Version, Jellyfin version? do you use additional jellyfin plugins? anything unusual in the jellyfin logfile? the jellyfin logs are located in /share/CACHEDEV1_DATA/.qpkg/jellyfin/logs/ and should have a name like log_20240730.log for todays log for example.

I did some casual testing on my TS-664's RAM consumption, I'm also using 32GB. There is not much else running on the system besides jellyfin right now. tested on my TS-664 with Intel N5105, QTS 5.1.8.2823 build 20240712 and jellyfin 10.9.7 right here from pdulvp.

My idle RAM consumption from the jellyfin process is at 386,7 MB after letting the NAS and jellyfin run idle for around one hour. With one 4k stream running form network it's at 557 MB and with 2 parallel 4k streams it's at 626,4 MB.

I think your RAM consumption is way too high. It could be that your RAM is faulty, you can check it by following the official QNAP guide, but you'll need additional periphery: https://www.qnap.com/en/how-to/faq/article/how-do-i-perform-a-memory-test-on-qnap-nas

if you're using an older NAS: many of the older CPUs don't officially support 32GB of RAM, that could also be the issue here. Since my CPU also officially only supports up to 16GB, I'm not sure how valid that is.

screenshots ![jellyfin-idle](https://github.com/user-attachments/assets/73614b31-ba66-4182-aed5-f87525a35dd3) ![jellyfin-1x4kstream](https://github.com/user-attachments/assets/a8a94fde-c0d5-46c2-925d-de4ab7f57aa2) ![jellyfin-2x4kstream](https://github.com/user-attachments/assets/516a7da0-afbe-42a3-9a99-b48aa11a1657)
OneCDOnly commented 3 months ago

sorry for the big screenshots, is there a way on github to put something like spoiler tags around it?

Yes: https://gist.github.com/pierrejoubert73/902cc94d79424356a8d20be2b382e1ab

tusquitoni commented 3 months ago

Hi,

Thank you for your reply. I have a TS-673A with Ryzen V1500B CPU and 32 GB RAM. I am on QTS 5.1.8.2823 and Jellyfin is the latest version uploaded here, 10.9.7.

This is the memory consumption just starting the server, without doing anything:

memory-jelly

Just scanning a folder in the library it shoots up to consume me almost 40% of the NAS RAM. I don't have any plugin installed. I don't know how to look at the log.

Comparing it with your RAM consumption, it is clear that there is something wrong with my NAS or my installation. I don't know how I could fix it.

Thank you very much.

robotreto commented 3 months ago

TS664 with 16GB, 16TB multimedia folder with >12000 MKV and MP4 files. Uses 1.5 GB RAM after startup, and 3.1 GB after a couple of hours.

Oednerich commented 3 months ago

sorry for the big screenshots, is there a way on github to put something like spoiler tags around it?

Yes: https://gist.github.com/pierrejoubert73/902cc94d79424356a8d20be2b382e1ab

thanks, thats actually very helpful! But when using it on uploaded screenshots directly in the window it will look like this:

my uploaded screenshots ![jellyfin-idle](https://github.com/user-attachments/assets/73614b31-ba66-4182-aed5-f87525a35dd3) ![jellyfin-1x4kstream](https://github.com/user-attachments/assets/a8a94fde-c0d5-46c2-925d-de4ab7f57aa2) ![jellyfin-2x4kstream](https://github.com/user-attachments/assets/516a7da0-afbe-42a3-9a99-b48aa11a1657)

Thank you for your reply. I have a TS-673A with Ryzen V1500B CPU and 32 GB RAM. I am on QTS 5.1.8.2823 and Jellyfin is the latest version uploaded here, 10.9.7.

ok so we're on mostly the same hardware, your cpu officially supports 32GB of RAM so I don't think that's an issue.

Just scanning a folder in the library it shoots up to consume me almost 40% of the NAS RAM. I don't have any plugin installed. I don't know how to look at the log.

to look at the log follow this guide from QNAP: https://www.qnap.com/de-de/how-to/faq/article/how-to-access-qnap-nas-file-system-by-winscp

After you're logged in, navigate to: /share/CACHEDEV1_DATA/.qpkg/jellyfin/logs/

better copy this path and paste it in winSCP or activate "show hidden files" in winSCP, otherwise you won't see the /.qpkg/ folder.

Comparing it with your RAM consumption, it is clear that there is something wrong with my NAS or my installation. I don't know how I could fix it.

only options I'm seeing right now are checking the jellyfin logfiles and doing a memory test like I suggested in my first answer. Check the QNAP guide, if you have questions about it, just ask. Did you buy the NAS with the RAM already installed or did you upgrade it yourself? In the latter case, you could try going back to the original RAM and see if it makes a difference.

OneCDOnly commented 3 months ago

@Oednerich

thanks, thats actually very helpful! But when using it on uploaded screenshots directly in the window it will look like this: my uploaded screenshots

Ah, I didn't know this. 🤓

So, I messed with it a bit and found you need a line space after the closing summary tag and before the image tag:

<details>
<summary>your uploaded screenshots</summary>

![jellyfin-idle](https://github.com/user-attachments/assets/73614b31-ba66-4182-aed5-f87525a35dd3) ![jellyfin-1x4kstream](https://github.com/user-attachments/assets/a8a94fde-c0d5-46c2-925d-de4ab7f57aa2) ![jellyfin-2x4kstream](https://github.com/user-attachments/assets/516a7da0-afbe-42a3-9a99-b48aa11a1657)
</details>
your uploaded screenshots ![jellyfin-idle](https://github.com/user-attachments/assets/73614b31-ba66-4182-aed5-f87525a35dd3) ![jellyfin-1x4kstream](https://github.com/user-attachments/assets/a8a94fde-c0d5-46c2-925d-de4ab7f57aa2) ![jellyfin-2x4kstream](https://github.com/user-attachments/assets/516a7da0-afbe-42a3-9a99-b48aa11a1657)
Oednerich commented 3 months ago

@OneCDOnly

thanks! oh I feel a bit stupid right now, I thought about adding spaces but then thought "why would this matter" and didnt try.

robotreto commented 1 month ago

As I too have this ever increasing memory consumption on my qnap (growing from 550MB to 4GB in 2 weeks), I took the time to download the newest source (10.10.0) and compiled it under windows to analyze the memory consumption with the VS2022 debugger. During the initial library scan, RAM usage went up to 2.5GB. Subsequent re-scans of the libraries did not add to that. Then restarted the server, initial RAM usage was 400MB. First library rescan jumped to 600MB. All subsequent rescans (I tried more than 10) did not add any significant RAM usage, so it seemed stable. I also checked if the Garbage-Collector was called after library scans, and it was indeed called. So it seems indeed to be very hard to reproduce the problem. Maybe the memory-administration in windows is different than in Linux ?