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

Huge Memory Leak #109

Open
iDhanush opened this issue Apr 28, 2023 · 7 comments
Open

Huge Memory Leak #109

iDhanush opened this issue Apr 28, 2023 · 7 comments
Labels
inspecting Currently looking into this issue

Comments

@iDhanush
Copy link

In a 64GB Dedicated Server i ran The Bot For 7h with 4 clients

After 2 hours uptime the memory usage was about 5GB with a total of 400 workload (sum of all workloads of bot in approx)

After 7 hours of uptime the memory usage was a whopping 16GB with just total load of less than 70

So we can say that the memory is not getting released even a bit even when load became 1/5th of the initial load

I whould really like to see an end to this 🥲, idk if the FileStream code or if the pyrogram itself is leaking memory but either way it's clear that there is a memory leak and i think it's from the media_sessions cuz the size of media_sesssion had also respectively without going down again

if u need any more info or want to test any patches I'll be there for u xd

usageStatsScreenShot

@EverythingSuckz EverythingSuckz added the inspecting Currently looking into this issue label Apr 28, 2023
@EverythingSuckz
Copy link
Owner

Yeah, I'm aware of this from this post and it seems like I'll have to profile the whole code to see where all the memory is being used. Your USE_SESSION_FILE var is set to True, right?

@iDhanush
Copy link
Author

Yep

@HydroHax
Copy link

Mine works fine ig

@pdisk
Copy link

pdisk commented Apr 29, 2023

The Workloads are not getting released correctly
The finally block in yield file which is supposed to release the work load when it's done streaming doesn't get closed if the client seeks the video hence while streaming a new client will be assigned each time which makes even more ram consumption cuz the media session of each client now has to cache that file

In other words if the client seek the video 4 times it gets handled by 4 clients and create session and cache for each of those files in media session of each clients hence increasing the ram consumption

@FelinaHD
Copy link

ho we can solve this problem?

@Ygohel18
Copy link

I have used daemon service and timer to auto stop and start again every 3 hour? does it work?

@EverythingSuckz
Copy link
Owner

I have used daemon service and timer to auto stop and start again every 3 hour? does it work?

I'm working on a fix. I'll update it soon

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

No branches or pull requests

6 participants