Skip to content

Memory leak after playback of many episodes #86

Closed
RussianNeuroMancer opened this Issue Oct 21, 2012 · 16 comments

4 participants

@RussianNeuroMancer

Hardware:
Zotac ZBOX AD03BR Plus
AMD E-350 with Radeon HD 6310
1 Gb system memory, 1 Gb UMA Buffer Size

Software:
Distribution: Ubuntu 12.10 x86_64
Linux: 3.5.0-17
swap: 1.7 Gb
fglrx: 9.000, installed from Ubuntu repository
XBMC: 12.0~git20121006.1450-af30ed9-0quantal

DDX,EnableTearFreeDesktop is set to 0.
MCIL,DigitalHDTVDefaultUnderscan is set to 0.
MCIL,HWUVD_H264Level51Support is not registered in PCS database
Compiz is not used, LightDM login directly into XBMC. PulseAudio is not used.
Adjust refresh rate enabled in XBMC on start/stop, after 1.5s.
Release used to reproduce this issue: [ReinForce] Durarara!! (BD 1920x1080 x264 FLAC)

  1. Test with hardware decoder:
    With enabled XvBA decoder support XBMC not able to create decoder session after playback 12-13 episodes. XBMC debug log contain this error messages repeated hundreds of times:
    06:07:19 T:140508261226240 DEBUG: CDVDPlayerVideo - video decoder returned error
    06:07:19 T:140508261226240 DEBUG: CDVDPlayerVideo::CalcDropRequirement - hurry: 0
    06:07:19 T:140508261226240 ERROR: XVBA::CreateSession - failed to create decoder session, line 617
    06:07:19 T:140508261226240 ERROR: Decoder failed with following stats: m_surfaceWidth 1920, m_surfaceHeight 1088, m_vidWidth 1920, m_vidHeight 1080, coded_width 1920, coded_height 1088
    06:07:19 T:140508261226240 ERROR: ffmpeg[A0FF9700]: [h264] get_buffer() failed (-1 0 (nil))
    06:07:19 T:140508261226240 ERROR: ffmpeg[A0FF9700]: [h264] decode_slice_header error
    06:07:19 T:140508261226240 ERROR: ffmpeg[A0FF9700]: [h264] no frame!
    06:07:19 T:140508261226240 ERROR: Decode - avcodec_decode_video returned failure
    06:07:19 T:140508261226240 DEBUG: CDVDPlayerVideo - video decoder returned error
    06:07:19 T:140508261226240 DEBUG: CDVDPlayerVideo::CalcDropRequirement - hurry: 0
    06:07:19 T:140508261226240 NOTICE: XVBA::Check - Attempting recovery
    Probably video memory is full. I have same error in XBMC on my laptop (Radeon HD 6620G) where I use TearFreeDesktop on two displays and just 512 Mb of UMA Buffer Size.

  2. Test with software decoder:
    First time playlist with 26 episodes playback without issues (except software decoder was very slow but it was expected due to CPU speed). I start playlist again and few hours later (around 30-35 episodes in the amount) XBMC was terminated by oom-killer: http://xbmclogs.com/show.php?id=11113

  3. Results of requested test:
    Playback of first five seconds of first episode twenty-five times.
    XvBA disabled, adjust refresh rate disabled: 92M -> 248M
    XvBA disabled, adjust refresh rate enabled: 93M -> 252M
    XvBA enabled, adjust refresh rate disabled: 96M -> 313M
    XvBA enabled, adjust refresh rate enabled: 95M -> 415M
    I get memory info from htop (RES column). First value recorded right before test. Second value recorded around half-minute after test.

@FernetMenta
Owner

Do you see this issue with other videos too?
@fritsch how often can you switch channels, any limit? I am wondering why this has not been reported earlier. Seems not only XvBA is affected. Maybe a problem in ffmpeg?

@fritsch
fritsch commented Oct 22, 2012

@FernetMenta:
Not that easy to test. With 1GB UMA size i switched now approx 50 times without issue. I cannot change the UMA size to a lower value right now - as my gf is watching TV. Memory usage stayed more or less constant, while doing this. This is with 50hz and 50i content. Memory staid between 199MB and 211MB

I also switched 20 times to the killa sample (24p) and it seems that increased the memory usage to 350MB - so it seems that adjust refresh rate somehow takes a bunch of memory for breakfast?

Will retry next time with smaller UMA size of 512MB.

@FernetMenta
Owner

so it seems that adjust refresh rate somehow takes a bunch of memory for breakfast?

hmm

XvBA disabled, adjust refresh rate disabled: 92M -> 248M
XvBA enabled, adjust refresh rate disabled: 96M -> 313M

How would you explain this?

@fritsch
fritsch commented Oct 24, 2012

Adjust RefreshRate seems "safe".
Is it the same with vdpau? Do some surfaces survive in memory? When they are pushed through xvba / vdpau?

I don't have a vdpau setup - could you measure it with vdpau?

@FernetMenta
Owner

At the first glance it looks like a leak but no matter how often I start e.g. killa sample I don't get above a peak value which is close to 500m.

@RussianNeuroMancer
What do you observe when setting UMA to 500? Why have you set it to 1GB? I don't even have a system which allows that.

@FernetMenta
Owner

Note that the driver defers e.g. deletion of texture memory. Memory might not be released until it is used by the next resource. Hence it it useless to observe RES of top.
A 1:1 ratio of vram and system ram is very odd.

@RussianNeuroMancer

@FernetMenta

Do you see this issue with other videos too?

I need to check item 1 and 2 with another 1080p release, or just check item 3 with few other video-files?

What do you observe when setting UMA to 500?

I doesn't check yet.
Latest stable UEFI for this board doesn't allow to select more than 256 Mb UMA Buffer Size (now I use UEFI beta build with unlocked UMA Buffer Size settings). Before, when I have 256 Mb UMA Buffer Size, I get issue 1 after playback five episodes. So I guess if I select 512 Mb UMA Buffer size, I'll get issue 1 after playback 8-9 episodes - I need to verify this? (I talk only about issue 1 here because I doesn't check scenario from issue 2 and issue 3 on 256 Mb UMA Buffer Size.)

Why have you set it to 1GB?

No special reason. I just select maximum to see, will I get any problems with this UMA Buffer Size, or not.
If there were no problems, then I planned to check playback with 512 Mb UMA Buffer Size, but as you can see there are problems even with 1 Gb UMA Biffer Size .

I don't even have a system which allows that.

My laptop (AS7560G) are the same - locked 512 Mb UMA Buffer Size. With active KWin, two displays and TearFreeDesktop, XvBA in XBMC doesn't work at all (same errors like in item 1, so probably same problem - not enough video memory, because TearFreeDesktop need to take care of two displays so it use a lot of video memory). I know XBMC shouldn't work under compositor and enabled TearFreeDesktop, but I guess this information may be useful.

Hence it it useless to observe RES of top.

Ok, what instrument I should use to check issue 2 next time?

A 1:1 ration of vram and system ram is very odd.

You propose to select 512 Mb UMA Biffer Size before run follow tests?

@wsnipex
@FernetMenta
Owner

I don't think there is a mem leak at the application level. I already run it with valgrind and did not find anything which can cause such a big leak. Furthermore I can't reproduce it on a AD02.
I think it is either related to new kernel in quantal, fglrx, or beta bios, or odd vram to system ram ratio.

@RussianNeuroMancer

@FernetMenta

or beta bios

As you probably know, with latest stable UEFI and just 256 Mb UMA Buffer Size I have much more problems (if MCIL,HWUVD_H264Level51Support enabled - video stuttering after playback 1-3 episodes) so not likely it's related to beta status of UEFI that I use right now.

related to new kernel in quantal

I also have same problem on precise kernel. Quote from my previous commentary:

Before, when I have 256 Mb UMA Buffer Size, I get issue 1 after playback five episodes.

That was on Precise.

Furthermore I can't reproduce it on a AD02.

Using same video for test?

@FernetMenta
Owner

Using same video for test?

If you send me a link I can try with same video as you have used.

@FernetMenta
Owner

please reopen if issue still exists.

@RussianNeuroMancer

please reopen if issue still exists.

Seems like I doesn't have rights to reopen it.

Current situation with this issue:
Test with hardware decoder doesn't lead to "XVBA::CreateSession" error anymore (VRAM leak probably fixed on driver side). However another memory leak is still present - XBMC process size eventually growing.
Size of XBMC process before test: 83 MB,
After playback 26 episodes: 485 MB,
After playback 52 episodes: 734 MB.
So without XBMC restart or system reboot process eventually consume all available memory and will be terminated by OOM-killer.

That was test with hardware decoder. I need to run another test with software decoder?

Kubuntu 13.04 x86_64, XBMC 12.2~git20130521.1119, Catalyst 13.6 beta.

@FernetMenta
Owner

So without XBMC restart or system reboot process eventually consume all available memory and will be terminated by OOM-killer.

did that actually happen? the driver releases memory when it's in the mood of releasing memory, not when the user stops playback.

@RussianNeuroMancer

did that actually happen?

No.

the driver releases memory when it's in the mood of releasing memory, not when the user stops playback.

Ok, I will check free memory later.

@RussianNeuroMancer

the driver releases memory when it's in the mood of releasing memory, not when the user stops playback.

I do another round of testing. This time XBMC process take around 670 MB (but this time I playback less episodes). After 24 hours of idle just 55 MB was released, so size of XBMC process currently is 615 MB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.