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
Video decoding falling behind can cause large memory consumption #3519
Comments
Have you tried without any custom videos you have loaded? |
Okay so I've tested the following:
I've included the specific video file that is causing the leak over here |
Can you check/include log files? I'd suspect something may show up there, or something in Ctrl-f2 or Ctrl-f3 view that gives an idea of what is going wrong. |
After some further testing I decided to drop this video in on the other tournament scenes, namely, the gameplay, mappool and seeding scene. All of these started to behave the same way as the showcase scene. In the CTRL+F2 menu the Garbage Collection Gen0 keeps increasing with 1 every 1-2 seconds. All the other values stayed the same or fluctuated across the same values. I have included the performance and runtime logs with these menus open. This happened with both of the videos, but the logs are with the 2160p video in place. It now seems like the leak is also there with just the 1080p video, but it's less noticeable due to the memory consumption being lower. |
Yup, very reproducible with the attached video (to the point that I'd warn to not try to reproduce this on a low-memory system, as this fills up memory quite quickly, so better to watch out to not stall the entire system on a swap). After prodding this with dotmemory it seems that the decoding loop is doing a lot of allocations on the large object heap, therefore I assume introducing memory pressure via fragmentation: Looking at the source Weirdly enough even setting GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; doesn't really do anything. From these messages that show in console:
I assume the reason for this is that due to the time it takes to decode, the decoding loop falls behind so far that the compaction doesn't even manage to keep up with the rate of allocations anyway. In fact, as long as this branch of decoding doesn't execute (you can emulate that at all times by artificially setting Unfortunately the requested buffer size does not seem to be constant, so at current the best solution I can see is to keep a single buffer instance which is enlarged whenever necessary and manually keep byte count of what data is valid for a given packet to avoid double-reading stale buffer data, but even that doesn't stop the memory usage from uncontrollably increasing when video is too far out of sync. |
Going to move this to framework and add to may milestone (seems like something we should get fixed asap) |
I detected memory leak when trying to refactor video decoding half a year ago, with 1080p video in visual test. |
Describe the bug:
The tournament showcase screen I recently PR'ed ppy/osu#8859 is leaking memory. I first encountered this issue when livestreaming a showcase myself using this screen.
So I decided to take a look in the debugger and checking all the scenes in lazer's tournament mode. Apparently only the showcase screen showed symptoms of memory leaking. In the graph shown you can see it linearly increasing and then flattening. The flattening is me switching to the other scenes and keeping it on for a few seconds. After that I switched back to the showcase screen and the memory usage started increasing again.
Screenshots or videos showing encountered issue:
osu!lazer version:
2020.429.0 and ppy/osu@3bf58b7
Logs:
network.log
performance.log
runtime.log
The text was updated successfully, but these errors were encountered: