Opened 13 months ago
Closed 12 months ago
#18654 closed bug (fixed)
Memory leak - MediaPlayer
Reported by: | kim1963 | Owned by: | pulkomandy |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta5 |
Component: | Audio & Video/Codecs | Version: | R1/beta4 |
Keywords: | regression | Cc: | |
Blocked By: | Blocking: | ||
Platform: | All |
Description (last modified by )
Memory leakage when playing audio files with a MediaPlayer. Playing a big singular file. All audio formats create a leakage of memory. Reproduction of video files does not lead to a memory leak . Checked for 64 bits 57367 night build.
Change History (27)
comment:1 by , 13 months ago
Description: | modified (diff) |
---|
comment:2 by , 13 months ago
comment:3 by , 13 months ago
Component: | Audio & Video → Audio & Video/Codecs |
---|---|
Owner: | changed from | to
follow-ups: 5 8 15 comment:4 by , 13 months ago
Looks like this may be a kernel leak and not a userland one.
Is this reproducible in any VMs or only on bare metal?
comment:5 by , 13 months ago
Replying to waddlesplash:
Looks like this may be a kernel leak and not a userland one.
Is this reproducible in any VMs or only on bare metal?
Perhaps the code check with a static analyzer can clarify something? https://habr.com/ru/companies/pvs-studio/articles/461255/
comment:6 by , 13 months ago
I checked large audio files in other player / QMplay2 and QMMP /. There are no problems with the memory leak.
comment:7 by , 13 months ago
Can confirm this looks like something kernel/MediaKit related: i'm seeing the same behavior in StreamRadio. If left running and playing a stream, RAM usage climbs steadily without stop. Bug is easily reproducible this way.
I'm listening some music now, it's been ~20min and RAM usage is nearing 850MB. (edit. hrev57353, baremetal)
comment:8 by , 13 months ago
Replying to waddlesplash:
Looks like this may be a kernel leak and not a userland one.
Is this reproducible in any VMs or only on bare metal?
On bare metal.
Unfortunately, I have no way to check it in a virtual machine.
follow-up: 10 comment:9 by , 13 months ago
Does RAM usage go back down once MediaPlayer/StreamRadio is closed?
comment:10 by , 13 months ago
comment:11 by , 13 months ago
Hrev 57365, x64, bare metal Memory usage keeps growing playing tracks in loop or playing playlists
follow-ups: 13 14 comment:12 by , 13 months ago
For StreamRadio the rssue is possibly different: the entire stream is kept in memory forever due to the way the media kit implements http streams.
Also, I don't seewhy this would point to a kernel problem in either case, more likely it is a media kit (or network kit in the case of streamradio) problem.
In any case pl ase report the streamradio problem to StreamRadio bugtracker first, it is not a good idea to investigate two possibly related but different issues in the same bugreport (we can't split a bugreport in trac, but we can always close one bugreport as aduplicate of another if they end up being the same)
comment:13 by , 13 months ago
Replying to pulkomandy:
For StreamRadio the rssue is possibly different: the entire stream is kept in memory forever due to the way the media kit implements http streams.
I can confirm that. I saw it and even started rewriting it back when StreamRadio got a bit of attention due to the removal of some deprecated API, but other issues got in the way. There's already a report in its bugtracker.
comment:14 by , 13 months ago
Replying to pulkomandy:
In any case pl ase report the streamradio problem to StreamRadio bugtracker first, it is not a good idea to investigate two possibly related but different issues in the same bugreport (we can't split a bugreport in trac, but we can always close one bugreport as aduplicate of another if they end up being the same)
I spun up two VMs, one with Beta4 and another with hrev57367. Installed StreamRadio and started the same stream on both VMs. After 1hr of streaming, RAM usage sits at ~350Mb on Beta4, and nearing 2Gb on said nightly. So I still think there's something wrong @ OS-level, and maybe both leaks add up?
In any case I won't test w/StreamRadio anymore (until needed/asked for), to isolate that issue.
comment:15 by , 13 months ago
Replying to waddlesplash:
Looks like this may be a kernel leak and not a userland one.
Is this reproducible in any VMs or only on bare metal?
I checked the memory leak on the release of 64 bits 56578+93 - there is no memory leakage!
comment:16 by , 13 months ago
Keywords: | regression added |
---|---|
Milestone: | Unscheduled → R1/beta5 |
Moving to r1beta5 since it's a regression
follow-up: 18 comment:17 by , 13 months ago
Any chance this commit could be the culprit? https://github.com/haiku/haiku/commit/9858be4f63c2148aa18bd65e139586e3e837f8c2
comment:18 by , 12 months ago
Replying to jackburton:
Any chance this commit could be the culprit? https://github.com/haiku/haiku/commit/9858be4f63c2148aa18bd65e139586e3e837f8c2
Please someone test with a hrev before hrev57350.
comment:19 by , 12 months ago
Testing MediaPlayer side-to-side on fresh Haiku VMs, with a sample ~35min 85Mb MP3 file:
hrev57346: No apparent leak, RAM usage stays on ~22Mb after 15+ min. Fast seeks do not increase memory usage.
hrev57352: Very obvious leak, RAM usage ~100Mb after 3min and climbing at ~0.5Mb/sec. Fast seeking increases leakage to ~2Mb/sec.
comment:20 by , 12 months ago
I suspect we need to call av_frame_unref AFTER we call avcodec_receive_frame().
At least, that's why I understand from here:
https://stackoverflow.com/questions/37907194/audio-decoding-memory-leak-ffmpeg
follow-ups: 22 23 comment:21 by , 12 months ago
I suspect we need to call av_frame_unref AFTER we call avcodec_receive_frame().
That's already what should happen: the frame can be dereferenced just before decoding the next one, when _DecodeSomeAudioFramesIntoEmptyDecodedDataBuffer is called again.
But something is clearly not working as I think here?
comment:22 by , 12 months ago
Replying to pulkomandy:
I suspect we need to call av_frame_unref AFTER we call avcodec_receive_frame().
That's already what should happen: the frame can be dereferenced just before decoding the next one, when _DecodeSomeAudioFramesIntoEmptyDecodedDataBuffer is called again.
Right, I see now.
comment:23 by , 12 months ago
Replying to pulkomandy:
But something is clearly not working as I think here?
At least calling memset() then av_frame_unref() doesn't make sense.
comment:24 by , 12 months ago
There's some other problem here though, because it's kernel memory usage that's increasing, not application memory usage. What's up with that?
comment:26 by , 12 months ago
because it's kernel memory usage that's increasing, not application memory usage
At least ProcessController doesn't show kernel memory usage increasing, so maybe there's some problem with the other screenshotted application.
Originally reported here https://discuss.haiku-os.org/t/memory-leak-mediaplayer/ Note that when kim1963 says a big file, it's about an eleven hours of audio.