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
[Bug]: Memory Leakage with YouTube video #292
Comments
Thanks for opening this issue, a maintainer will get back to you shortly! In the meantime:
|
@ioangatop Few questions:
|
|
@ioangatop Do with USB camera feed, I want to eliminate possibility that OpenCV itself is responsible. |
@ioangatop Wait isn't this multi-threading? |
it does look like this: [opencv](opencv/opencv#13255)
Hmmm not sure |
this is how it looks like in the server
|
Yes it is. This is case of infamous GIL which makes it impossible to use same resource on multiple threads, hence whatever high end your PC specs are or optimizations you perform, it will going to throttle the performance or cause leaks. |
@ioangatop The GIL is per Python process, a Docker container may have 1 or many Python processes, each with it's own GIL. |
@abhiTronix Thank you for the pointer, I'll take a look at it. However, I would like to mention that I have multiple other microservers that work with |
@ioangatop The problem here is that vidgear itself uses Multi-Threading in its CamGear API: vidgear/vidgear/gears/camgear.py Lines 421 to 431 in 6af7aef
And using threading over threading is bad. |
@ioangatop Good news is that I'm working on new library that will eliminate use of threading and will produce high performance frames with FFmpeg. Follow issue #148 |
@abhiTronix ah right, that makes sense! Does Vidgear has any generator, like I track the issue, super exciting! |
You mean starting CamGear directly from terminal? No, but can be added easily. |
No, I want to start vidgear to fetch frames from a source and put them in a message broker (like redis) in the background. Like, senting a POST request, |
@ioangatop Isn't |
Ok you meant python generator, no. |
tbh it doesn't matter, just to run in the background |
No this is invalid. You want your python script to run in background or just vidgear? |
Because vidgear's |
script that runs vidgear in the background. Highlevel:
and the process should be smthing like
|
@ioangatop Why don't you use asyncio python? It is thread safe and you could easily create custom generator something like https://abhitronix.github.io/vidgear/latest/gears/webgear/advanced/#using-webgear-with-a-custom-sourceopencv |
@abhiTronix I think thats a good solution, I'll take a look at it! Thank you! |
Yes, I was going to say this that you can run asyncio generator with multi-threaded CamGear in the background without worrying about GIL. I'm using it already in WebGear: vidgear/vidgear/gears/asyncio/webgear.py Lines 366 to 426 in 6af7aef
|
Hi! These days I came across this issue, where it appears that the memory usage keeps increasing as I stream a video.
In this example, it increases even more, but in a microserver setting, like launching this script in a REST-API server, there is a steady but small increase over time.
In this scenario, I run the script with docker;
The text was updated successfully, but these errors were encountered: