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

Memory Leak #402

Closed
VortexAcherontic opened this issue Jun 23, 2023 · 11 comments · Fixed by #404
Closed

Memory Leak #402

VortexAcherontic opened this issue Jun 23, 2023 · 11 comments · Fixed by #404
Labels
bug Something isn't working

Comments

@VortexAcherontic
Copy link

VortexAcherontic commented Jun 23, 2023

Hello there,

As the title says, Tube Converter has serious memory leak issues.
The below screenshots shows the memory progression of my system with only my basic desktop and Tube Converter running.

During downloading one or multiple videos the application allocates more and more system ram as if it would try to load the entire video files into memory.
Until the point the entire desktop starts to freeze because of memory issues.

As long as the application is idle it does not hog memory, only during download.

grafik

This is a screenshot from htop after my system started swapping.
As you can se 21% (of 16GiB + 16GiB swap) belong to Tube Converter.

grafik

tube_converter

I am using the Flatpak build on openSUSE Aeon.

@nlogozzo
Copy link
Member

Could you provide some more information for me?

  • how many downloads did you have running?
  • can you provide me with some of the urls, and settings for the download (file format, quality, use of aria2 or not, running in background or not, etc...)

Thanks

@nlogozzo nlogozzo added the bug Something isn't working label Jun 23, 2023
@VortexAcherontic
Copy link
Author

VortexAcherontic commented Jun 23, 2023

Hey there for the purpose of this bug report I downloaded this video file:
https://www.youtube.com/watch?v=lrf-GAYUOkQ
Only one download at a time and Tube Converter was active.

Settings I used:

  • File Type: MP4
  • Quality: 3840 x 2160
  • Subtitles: None
  • Advanced options: All off

Application settings (all default but I list them for the purpose of this ticket):

  • Theme: System

  • Complete Notification Trigger: For each download

  • Allow Running in background: Off

  • Amount of active downloads: 5

  • Overwrite existing files: On

  • Speed Limit: 1024 (Did not enable speed limit for the download)

  • Use aria2: Off

  • Subtitle Lagnguages: de,deu

  • Cookie File: None

  • Disallow Conversions: Off

  • Embed Metadata: On

  • Embed Chapters: Off

But as I first encountered the issue I was downloading a non listed 1080p video from about 5h length (past broadcast)
The settings where the same except the resolution which was 1080p.

@VortexAcherontic
Copy link
Author

VortexAcherontic commented Jun 23, 2023

Forgot to mention I run version 2023.6.2, which seems to be the latest.

@nlogozzo
Copy link
Member

Well downloading an hour long 2K video or even a 5 hour video is definitely going to eat all your ram...that's just the nature of yt-dlp and ffmpeg TBH.

This would be considered a "memory leak" if the usage doesn't go down after the video is done. If it does go back down, then this isn't an issue.

What I would suggest is maybe using aria2 for these large videos and it splits and processes the video in chunks.

@VortexAcherontic
Copy link
Author

The memory was only freed after closing the application.
But as long as Tube Converter is running or let's say still open after the download has completed the RAM is still occupied.

Running yt-dlp directly from command line didn't caused this issue and other yt-dlp front-ends don't do this either so I was suspecting something is weird with Tube Converter.

Also tried: Video Downloader which claims to be an yt-dlp (not to be confused with youtube-dl) front end as well and the RAM usage keep consistent downloading the same video file. (36.9 MB)
grafik

BUT I can confirm enabling aria2 solved the issue entirely, so I gonna close the issue here.

Thank you for your time looking into this ❤️

@nlogozzo
Copy link
Member

Like I said it's probably all of the ffmpeg processing then. Turning off embed metadata and disallow conversions might help, while keeping aria2 off. But I'll look into it.

Either yeah, glad it works with aria2 no problems. Like I said aria2 splits it into chunks so it definitely saves resources and is probably always recommended for larger videos.

@nlogozzo nlogozzo reopened this Jun 23, 2023
@nlogozzo
Copy link
Member

I'm going to reopen this as I said I would like to try and make it where it reclaims the memory at least when the download is done.

@soumyaDghosh
Copy link
Member

I'm going to reopen this as I said I would like to try and make it where it reclaims the memory at least when the download is done.

Though, not an expert, but can it be that somehow may be ffmpeg or yt-dlp were also running occupying this memory? Or, may be this is another situation when will GC kick in?

@nlogozzo
Copy link
Member

nlogozzo commented Jun 24, 2023

I have a feeling it's definitely ffmpeg. Using aria2 doesn't have this issue cause like I said it splits each video into chubcks and processes each chunk separately. Whereas without aria2, it downloads the entire video and passes the whole thing to ffmpeg, using a lot of memory.

I probably won't be able to fix the fact that it uses a lot of memory...but once the download finishes, that memory should be reclaimed and go down instead of staying high even with no download.

Might have to fix the way we dispose the downloads when done.

@nlogozzo
Copy link
Member

Ok I found the issue...I forgot to dispose of the DownloadProgressState object which is what reports the logs...So the logs were just building and building up without being cleaned up

@nlogozzo
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants