Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crazy memory leaks #4735

Closed
xnoreq opened this issue Aug 8, 2017 · 19 comments
Closed

Crazy memory leaks #4735

xnoreq opened this issue Aug 8, 2017 · 19 comments

Comments

@xnoreq
Copy link
Contributor

xnoreq commented Aug 8, 2017

mpv version and platform

mpv 0.26.0

Reproduction steps

hwdec=d3d11va-copy
opengl-backend=angle
hwdec-codecs=all

Add a bunch of videos to mpv. Mash the key bound to playlist-next.

Expected behavior

Bounded memory usage. Playing a ~5000 kbps bitrate full hd video I measure about 80 MB private working set.
I don't see a reason why memory usage should increase beyond that, especially when switching to lower bitrate videos.
grafik

Actual behavior

Memory usage grows until the system runs out of memory and mpv crashes or is killed.

After roughly 30 times playlist-next:
grafik

More detailed process stats also showing leaking handles:
Before:
grafik

After roughly 30 skips:
grafik

@xnoreq
Copy link
Contributor Author

xnoreq commented Aug 8, 2017

Further details:
A detailed look at the handles shows:

  • what seems to be graphics driver DirectX cache File & Section & Event handles leaking,
  • lots of threads leaking
  • the rest are countless unnamed Event & Mutant (mutex, semaphore) type handles leaking

@ghost
Copy link

ghost commented Aug 8, 2017

Can't reproduce. Missing log file.

@haasn
Copy link
Member

haasn commented Aug 8, 2017

Does setting hwdec=no fix it?

@xnoreq
Copy link
Contributor Author

xnoreq commented Aug 8, 2017

@haasn I'm not seeing these leaks with hwdec=no or hwdec-codecs=none.

@haasn
Copy link
Member

haasn commented Aug 8, 2017

Sounds like the solution is to stop using hwdec.

@xnoreq
Copy link
Contributor Author

xnoreq commented Aug 8, 2017

Or switch to another player that uses the same libav/ffmpeg hardware acceleration but doesn't leak at all.
Thanks and good luck.

@xnoreq xnoreq closed this as completed Aug 8, 2017
@ghost
Copy link

ghost commented Aug 8, 2017

Or you could just ignore the troll and post a log file.

ghost pushed a commit that referenced this issue Aug 9, 2017
Apparently this was broken by the "ctx->hwdec" check in the if condition
guarding the destroy call, and "ctx->hwdec = NULL;" was moved up
earlier, making this always dead code.

This should probably be refcounted or so, although that could make it
worse as well. For now, add a flag whether the device should be
destroyed.

Fixes #4735.
@ghost
Copy link

ghost commented Aug 9, 2017

Found it - the trick was that you really need multiple files to make it show up, and that the new d3d hwaccel code must be used.

@OneB1t
Copy link

OneB1t commented Jan 12, 2021

i have same issue is there any solution for this problem other than hwacel off?
Even after de6d3f8 it is still broken :-/

Also it looks like leak differs between different GPU architectures (it is leaking much less on my intel 630 based system than on AMD R290X system.)

@CounterPillow
Copy link
Contributor

Open a new issue instead of replying to a closed 3 year old issue.

@OneB1t
Copy link

OneB1t commented Jan 12, 2021

Why when this is probably still relevant?

@avih
Copy link
Member

avih commented Jan 12, 2021

It was reported for D3D11, and at least some leak was fixed at the D3D11 as a result of this report, and for 3 years there were no reports of leaks, so even if it is the same issue (which I think is unlikely), you should open a new issue with proper logs and evidence of the leak.

@OneB1t
Copy link

OneB1t commented Jan 12, 2021

I put it here as i have same symptoms as xnoreq it works fine without hwdec and it is broken with both d3d11va and dxva2
For me it looks like mpv-1.dll is not unloading display driver libraries on dispose when hwdec is used

this is how it steadily eats memory with each new media loaded (im reloading complete mpv.dispose() is called between each play)
image

when hwdec=off this memory leak is not occuring

here is trace log for this problem but as im using c# mpv wrapper (Mpv.NET) im not sure if log will be useful. There is nothing about dispose of loaded modules
https://0bin.net/paste/YPupCNHd#+6+sl2XZagkFfaYoPeiQ08pQbC2gnvaaluvmx2L+Y96

@avih
Copy link
Member

avih commented Jan 12, 2021

It doesn't look like a leak to me, certainly not anywhere near the OP issue and report. Please open a new issue, with log, and better evidence. It's the last time I'm requesting it, and any further comments you post here will not get any response.

@avih
Copy link
Member

avih commented Jan 12, 2021

Also, if you use mpv.net then report it to mpv.net. If you report it here for mpv then use mpv itself.

@OneB1t
Copy link

OneB1t commented Jan 12, 2021

Does not really matter what wrapper is used as this is not issue of wrapper itself (as with hwdec off it works perfectly fine) wrapper correctly calls "MpvTerminateDestroy TerminateDestroy"

image
This is how leak looks like on AMD card with video reload every 5 sec (it is much worse than on intel)

@CounterPillow
Copy link
Contributor

OPEN A NEW ISSUE EVERYONE ELSE WHO COMMENTED ON THE ORIGINAL ONE DOESN'T NEED TO RECEIVE NOTIFICATIONS FOR YOUR COMMENTS

@OneB1t
Copy link

OneB1t commented Jan 13, 2021

Maybe that is the reason why i want to reuse this issue ;)

@mpv-player mpv-player locked as resolved and limited conversation to collaborators Jan 13, 2021
@Akemi
Copy link
Member

Akemi commented Jan 13, 2021

here we go. comments are locked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants