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

Possible memory leak? #1192

Open
bunkbail opened this issue Oct 19, 2024 · 6 comments
Open

Possible memory leak? #1192

bunkbail opened this issue Oct 19, 2024 · 6 comments

Comments

@bunkbail
Copy link

I'm new to video2x and I'm trying to use anime4k via libplacebo, no matter what I do the program will crash due to out of memory situation. I've only tried version 6.0.0-beta3. I've tested both Qt GUI version on Windows and CLI version on Linux via Docker. Video process managed to go further on Linux due to swap space but OOM will occur regardless. I have 16gb of RAM (same amount of swap) and I saw the process memory usage grew up to 32gb before OOM hits on Linux.

@bunkbail
Copy link
Author

A workaround I'm using right now is to split the original files into chunks of 1 min videos and process them that way. Every relaunches of video2x will reset the memory consumption so the leak won't be happening while processing each chunks. Here's a sample script that I'm using right now:
https://gist.github.com/bunkbail/c573be00d4640779742511e8b1bbfacc

@k4yt3x
Copy link
Owner

k4yt3x commented Oct 19, 2024

Interesting. Could you provide the command used? I'll profile the code with valgrind.

@bunkbail
Copy link
Author

this is what i use on docker:

docker run --gpus all --privileged -it --rm -v $PWD/data:/host -v /home/bunkbail/video2x-docker/videos:/videos -v /home/bunkbail/video2x-docker/output:/output ghcr.io/k4yt3x/video2x:6.0.0-beta.3 -i /videos/Sleepy\ Princess\ in\ the\ Demon\ Castle\ -\ S01E01.mkv -o /output/Sleepy\ Princess\ in\ the\ Demon\ Castle\ -\ S01E01.mkv -f libplacebo -s anime4k-mode-a -w 1920 -h 1080 -c libx265 -p medium -q 22

but the GUI version on windows also suffers from the same thing

@k4yt3x
Copy link
Owner

k4yt3x commented Oct 20, 2024

I ran it for a five-minute ish video and I'm not seeing any major leaks. I don't think the definitely lost one is from my code either. Even if it is, it's only 192 bytes.

image

Can you monitor the memory usage situation over time in your task manager or something and provide more details? So far I haven't been able to reproduce the issue.

@k4yt3x
Copy link
Owner

k4yt3x commented Oct 20, 2024

I've also monitored the memory usage. It consumed 5G of RAM pretty consistently. It's really interesting you're experiencing OOM issues. I wonder what went wrong.

image

@bunkbail
Copy link
Author

So if I use a common anime episode as input (as you can see from the above I use "Sleepy Princess in the Demon Castle"), I can see the video2x will start using 2gb right off the bat and it will increase 200MB or so of memory usage per sec until it finished processing the whole video. That's why making chunks of 60s of videos works as a workaround. Maybe you wanna try the file I use to see if you can replicate my issue? I took the files from here. I don't think the issue lies with my Linux system either seeing how it does the same exact thing on Windows as well.

My pc specs: Ryzen 5 5600X and RX 6900 XT

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

No branches or pull requests

2 participants