v17 Memory Leak in PVR?
#1
Hi!

I've been doing some experimenting today, and I believe I've found a memory leak. I'm using a Pi 3 with the OSMC distribution but I'm happy to try other combinations to rule things out. Here's what I've observed so far, and apologies for the lengthy post, just wanted to try and cover as much as I could.

I've really done the bare minimum to produce this leak after writing the OSMC image to the card. This is essentially a step-by-step list of what I've done to create this leak, with some memory observations from bcmstat.sh

1) install OSMC_TGT_rbp2_20160306.img to SD, insert into Pi3. (Kodi 16.0)

2) connected ethernet, hdmi, usb keyboard, power - nothing else

3) boot Pi and let it settle until OSMC config appears

4) config as:
English
Europe/London
test17 hostname
leave SSH enabled
keep OSMC skin
decline newsletter

5) Settings -> Add-ons -> My Add-ons -> All -> DVBLink
configure:
set IP
enable

6) Settings -> System -> Video output -> 50Hz

7) Settings -> TV -> Enabled

8) ssh in as osmc user to get bcmstat.sh setup. I generally keep an ssh session or two always open from this point on, for watching memory usage etc.

9) enter Live TV Guide. After leaving it to settle (without starting a channel) I have 633,000 free memory approx (from bcmstat's Memory Free column)

10) start BBC ONE HD. Immediately after starting I'm at 600,000 free memory approx.
after 1 min: 585,000 free
after 5 min: 582,000 free
after 15 min: 582,000 free
after 30 min: 582,000 free
pretty happy this isn't leaking.

11) Stopped Live TV. Back up to 627,000 free sat at the TV Guide.


12) Time to try Kodi 17. Added the development apt line, as per the OSMC Forum thread, deb http://download.osmc.tv/dev/gmc ./

13) apt-get update, apt-get dist-upgrade: I now have rbp2-mediacenter-osmc 16.8-048.

14) rebooted for good measure, since kodi seems to have quit itself anyway when it got upgraded.

15) letting kodi settle entirely until there's no CPU usage and no iowait after reboot. Note that the skin has changed itself to Estuary. I changed no settings at all.

16) back at TV Guide but not playing yet: settles at 640,000 free.

17) start BBC ONE HD: Immediately after starting: 610,000 free
after 1 min: 587,000 free
after 5 min: 573,000 free
after 15 min: 528,000 free
after 30 min: 468,000 free
this is clearly leaking and from previous testing I know it will keep going down until the kernel OOM killer comes along.

18) For this test, I stopped TV playback after 30 min and then back at TV Guide it settles at 500,000 free.
So 140,000 memory approx has been permanently lost.

18) Disabled DVBLink client and enabled NextPVR client as a comparison. (Still about 500,000 free)

19) rebooted to get a clean slate for NextPVR testing. Left it alone until cpu and disk access settled.

20) Into TV Guide again: 633,000 free.

21) start BBC ONE HD: Immediately after starting: 602,000 free
after 1 min: 600,000 free
after 5 min: 542,000 free
after 15 min: 285,000 free

leak seems even worse this time than the previous test. But this shows the leak isn't isolated to one PVR client?


Finally, I ran it again with debug logging enabled, which is here (caution, 6MB!)
https://raw.githubusercontent.com/celswo...di.old.log

Also bcmstat output while that debug log was generating:
https://raw.githubusercontent.com/celswo...cmstat.log

Would appreciate any pointers on what to do next, whether I can debug this further, am I the only one seeing this, etc?
Reply
#2
Is there a more suitable place I should post this? Since this original post I've also verified OpenELEC does the same thing so it's not OSMC in particular either.
Reply
#3
In case anyone finds this many years later - fixed in https://github.com/xbmc/xbmc/pull/9578
Reply
#4
I think this issue is still present, or at least some kind of memory leak regarding PVR
Since the latest Milhouse builds starting from #6xx i regularly have Kodi Krypton crashes when running LiveTV (TVHeadend) for a longer period (minimal 3~4 hours)

http://forum.kodi.tv/showthread.php?tid=...pid2358988
http://forum.kodi.tv/showthread.php?tid=...pid2359198
Reply
#5
Which version of TVH were you running. Over the past couple of weeks there have been several memory leaks that were fixed in git-master. (In fact, looking at the commit log, there was a fix for a memory leak in the HTSP server that was fixed yesterday.)
Reply
#6
Yeah i also noticed a lot of mem leak commits (after i submitted my reply).

Currently i'm running 4.1-2125~g2d15eca, going to compile 4.1-2130~g55fec0f and see how that build functions.
I will report the results.
Reply
#7
Updated Milhouse to #621 and Updated TVH to 4.1.2130 this morning but issue is still there. Any idea how to troubleshoot this?
Last message in log before it stopped:
Code:
17:24:27 34878.515625 T:139829098899200  NOTICE: PVRManager - PerformChannelSwitch - switched to channel 'Nickelodeon HD / Spike Channel'
17:24:27 34878.515625 T:139829098899200  NOTICE: Creating Demuxer
17:24:29 34880.636719 T:139829098899200  NOTICE: Opening stream: 1 source: 256
17:24:29 34880.636719 T:139829098899200  NOTICE: Creating video codec with codec id: 28
17:24:29 34880.636719 T:139829098899200  NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
17:24:29 34880.636719 T:139829098899200  NOTICE: Opening stream: 2 source: 256
17:24:29 34880.636719 T:139829098899200  NOTICE: Finding audio codec for: 86016
17:24:29 34880.640625 T:139828347610880  NOTICE: CVDPAU::Release pre-cleanup
17:24:29 34880.640625 T:139828356003584  NOTICE: CMixer::OnExit: Output Thread terminated
17:24:29 34880.640625 T:139829098899200  NOTICE: Closing stream player 3
17:24:29 34880.640625 T:139829098899200  NOTICE: Closing stream player 4
17:24:29 34880.640625 T:139828632975104   ERROR: Got MSGQ_ABORT or MSGO_IS_ERROR return true (-1)
17:24:29 34880.640625 T:139828632975104  NOTICE: thread end: data_thread
17:24:29 34880.640625 T:139829098899200  NOTICE: waiting for teletext data thread to exit
17:24:29 34880.648438 T:139829098899200  NOTICE: Opening stream: 1 source: 256
17:24:29 34880.648438 T:139829098899200  NOTICE: Opening stream: 2 source: 256
17:24:29 34880.648438 T:139829098899200  NOTICE: Finding audio codec for: 86016
17:24:29 34880.648438 T:139829098899200  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
17:24:29 34880.648438 T:139829090506496  NOTICE: Previous line repeats 2 times.
17:24:29 34880.648438 T:139829090506496  NOTICE: Creating audio stream (codec id: 86016, channels: 2, sample rate: 48000, no pass-through)
17:24:29 34880.652344 T:139829098899200  NOTICE: Opening stream: 1 source: 256
17:24:29 34880.652344 T:139829098899200  NOTICE: Creating video codec with codec id: 28
17:24:29 34880.652344 T:139829098899200  NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
17:24:29 34880.652344 T:139829098899200  NOTICE: Opening stream: 2 source: 256
17:24:29 34880.652344 T:139828347610880  NOTICE: CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(1920x1080)
17:24:29 34880.675781 T:139829098899200  NOTICE: CDVDMessageQueue::GetLevel() - can't determine level
17:24:31 34882.144531 T:139828347610880  NOTICE: Previous line repeats 1 times.
17:24:31 34882.144531 T:139828347610880  NOTICE:  (VDPAU) screenWidth:1920 vidWidth:1920 surfaceWidth:1920
17:24:31 34882.144531 T:139828347610880  NOTICE:  (VDPAU) screenHeight:1080 vidHeight:1080 surfaceHeight:1088
17:24:31 34882.152344 T:139828632975104  NOTICE: COutput::OnStartup: Output Thread created
17:24:32 34882.929688 T:139828632975104  NOTICE: VDPAU::COutput::CreateGlxContext - created context
17:24:32 34882.929688 T:139828632975104  NOTICE: VDPAU::COutput: vdpau gl interop initialized
17:24:32 34882.933594 T:139828356003584  NOTICE: CMixer::OnStartup: Output Thread created
17:24:32 34882.933594 T:139828356003584  NOTICE:  (VDPAU) Creating the video mixer
17:24:32 34882.933594 T:139828632975104  NOTICE: VDPAU::COutput::InitBufferPool - Output Surface created

dmesg:
Code:
[34888.084823] Out of memory: Kill process 1182 (kodi.bin) score 810 or sacrifice child
[34888.084943] Killed process 1182 (kodi.bin) total-vm:4191644kB, anon-rss:2913916kB, file-rss:0kB, shmem-rss:0kB
[34888.583009] oom_reaper: reaped process 1182 (kodi.bin), now anon-rss:0kB, file-rss:32kB, shmem-rss:0kB
Reply

Logout Mark Read Team Forum Stats Members Help
Memory Leak in PVR?0