New Version on QNAP Memory Leak

Updated to 1.9.5.4339 last night. This morning I have out of memory messages in my log:

Type Date Time Users Source IP Computer name Content
Warning 2017/10/18 02:08:58 AM System 127.0.0.1 localhost [Kernel] Out-Of-Memory. Kill process 17172(Plex Transcoder). To reclaim memory resources, try disabling some applications or consider expanding the system memory (if possible).

This is on a QNAP with an Intel i3 and 16GB of RAM that was only transcoding a single stream that never had any memory issue prior.

What other apps are running?
Do you have / can you get the Plex logs which contain the activity from that time period ? (Settings - Server - Help - Download Logs)
If so, we can look at what it was doing. The transcoder and PMS have a deliberately small memory requirement on NAS boxes (some machines only have 2 GB of RAM).

Here’a copy of the logs:

I’m seeing several things in your logs.

  1. The database is very fragmented. This will consume memory as everything will be pulled into the cache.
  2. You have an intermittent internet connection.

First, let’s address the database and memory utilization.

Oct 17, 2017 17:02:30.289 [0x7f11bc9a1700] INFO - It's been 44659023 seconds, so we're starting scheduled library update for section 12 (TV Shows)
Oct 17, 2017 17:02:32.261 [0x7f11aefff700] WARN - SLOW QUERY: It took 300.000000 ms to retrieve 1 items.
Oct 17, 2017 17:32:30.290 [0x7f11be111700] INFO - It's been 13936371 seconds, so we're starting scheduled library update for section 17 (4K Movies)

Optimize the database. (Hover over libraries, expose the ellipsis, click it, select ‘Optimize Database’)
Settings - Server - Scheduled Tasks. Enable database optimization and backup

You also appear to have a rapid / frequent forced library update interval.

Oct 18, 2017 02:32:30.347 [0x7f11bbde9700] INFO - It's been 13968771 seconds, so we're starting scheduled library update for section 17 (4K Movies)
Oct 18, 2017 02:32:30.347 [0x7f11bbde9700] INFO - It's been 44691437 seconds, so we're starting scheduled library update for section 11 (Cartoons)
Oct 18, 2017 02:32:30.552 [0x7f11bbde9700] INFO - It's been 8396092 seconds, so we're starting scheduled library update for section 18 (DVR Recordings)
Oct 18, 2017 02:32:30.552 [0x7f11bbde9700] INFO - It's been 44691436 seconds, so we're starting scheduled library update for section 6 (Home Videos)
Oct 18, 2017 02:32:30.552 [0x7f11bbde9700] INFO - It's been 44692416 seconds, so we're starting scheduled library update for section 1 (Movies)
Oct 18, 2017 02:32:30.552 [0x7f11bbde9700] INFO - It's been 44693227 seconds, so we're starting scheduled library update for section 7 (Music)
Oct 18, 2017 02:32:30.553 [0x7f11bbde9700] INFO - It's been 44693225 seconds, so we're starting scheduled library update for section 16 (Music Video)
Oct 18, 2017 02:32:30.553 [0x7f11bbde9700] INFO - It's been 44693224 seconds, so we're starting scheduled library update for section 4 (Specials)
Oct 18, 2017 02:32:30.553 [0x7f11bbde9700] INFO - It's been 44693223 seconds, so we're starting scheduled library update for section 12 (TV Shows)
Oct 18, 2017 02:39:35.049 [0x7f11bd847700] ERROR - Error response for update: 3 (Agent does not handle the given media type).
Oct 18, 2017 02:39:35.063 [0x7f11bd847700] ERROR - Error response for update: 3 (Agent does not handle the given media type).
Oct 18, 2017 02:59:53.941 [0x7f11b9847700] ERROR - Gracenote: Found 0 albums for ID 2949767-4C319500C02ADA6204CF851B65074A78.
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 13970571 seconds, so we're starting scheduled library update for section 17 (4K Movies)
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 44693237 seconds, so we're starting scheduled library update for section 11 (Cartoons)
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 8397892 seconds, so we're starting scheduled library update for section 18 (DVR Recordings)
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 44693236 seconds, so we're starting scheduled library update for section 6 (Home Videos)
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 44694216 seconds, so we're starting scheduled library update for section 1 (Movies)
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 44695027 seconds, so we're starting scheduled library update for section 7 (Music)
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 44695025 seconds, so we're starting scheduled library update for section 16 (Music Video)
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 44695024 seconds, so we're starting scheduled library update for section 4 (Specials)
Oct 18, 2017 03:02:30.554 [0x7f11a35e9700] INFO - It's been 44695023 seconds, so we're starting scheduled library update for section 12 (TV Shows)
Oct 18, 2017 03:32:30.555 [0x7f11b2fff700] INFO - It's been 13972371 seconds, so we're starting scheduled library update for section 17 (4K Movies)
Oct 18, 2017 03:32:30.555 [0x7f11b2fff700] INFO - It's been 44695037 seconds, so we're starting scheduled library update for section 11 (Cartoons)
Oct 18, 2017 03:32:30.556 [0x7f11b2fff700] INFO - It's been 8399692 seconds, so we're starting scheduled library update for section 18 (DVR Recordings)
Oct 18, 2017 03:32:30.556 [0x7f11b2fff700] INFO - It's been 44695036 seconds, so we're starting scheduled library update for section 6 (Home Videos)

If you wish, you can enable “Update automatically” in Settings - Server - Library. This will eliminate the periodic forced rescan.
Also, while there, I recommend enabling partial scan. It will only scan what’s needed.

Please perform these steps and then we’ll evaluate the progress again

So you’re saying I should shut off “Update my Library Periodically”. I believe that’s a throwback to an old version when automatic was broken many moons ago. I’ll disable now.

I have library database optimization already turned on: “Optimize database every week” was checked. I forced the optimization, it only took a few seconds.

New logs: https://www.dropbox.com/s/5ka2weirybmxxf4/Plex_Media_Server_Logs_2017-10-18_16-12-58.zip

Yes, I’m suggesting:

  1. Enable partial scan
  2. Enable automatic detection
  3. Disable periodic scan

What this gives you:

  1. The specific item(s) you add are the only things scanned, about 1 minute after you add it
  2. PMS won’t do a full scan unless you do command it thereby making scans finish quicker

Well, that solves the issues you found in the logs, but what about the memory condition that I opened the thread about. :smile:

I see no references in the logs to anything getting terminated. That is a puzzle for me as well.
Can you replicate the fault in any way?

Also, I would like you to check the size of your PMS cache files.

cd `getcfg -f /etc/config/qpkg.conf PlexMediaServer Install_path`
cd "Library/Plex Media Server/Plug-in Support/Databases"
ls -la

Examine the size of the shm and wal files. If they are > 8 MB, I recommend rebooting. These files hold cached transactions which is also held in main memory as part of PMS memory space. Restarting PMS commits the cache to the main DB file and zeros the files