-
Notifications
You must be signed in to change notification settings - Fork 17
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
Fix memleaks related to un-freed mmal objs #6
Conversation
I've been using rascam in a long-lived process that periodically creates and drops a SimpleCamera (that has an encapsulated SeriousCamera) periodically or on demand. The process mainly hosts an actix-web HttpServer and periodically saves an image from the raspberry pi camera, or serves a live feed from it through the front-end. Eventually, creating SimpleCamera fails with the following error message: mmal: mmal_vc_component_create: failed to create component 'vc.null_sink' (1:ENOMEM) mmal: mmal_component_create_core: could not create component 'vc.null_sink' (1) Failed to activate SimpleCamera: MMAL error: Unable to create null sink for preview Status: ENOMEM It seems that rascam has a memory leak in GPU memory. Upon examination, I've discovered some pointers to mmal objects created with mmal_*_create that were never freed with mmal_*_destroy. This commit addresses this issue by cleaning up mmal objects which should prevent (or at least reduce) GPU memory leaks. Note that I've been checking the GPU memory of a Raspberry Pi 3B with the following commands: vcgencmd get_mem malloc vcgencmd get_mem reloc After applying this commit, the periodic usage of SimpleCamera appears to not leak the GPU memory. Signed-off-by: Stephen Seo <seo.disparate@gmail.com>
I've found that this test program will panic within 100 iterations without the PR applied, but will successfully run 100 iterations when it is applied:
This is with 128M allocated to the Raspberry Pi 3B GPU. |
Hi @Stephen-Seo, thank you very much for your PR. I've re-linked TravisCI. If you don't mind, could you amend and force push so we can get the green light? Thanks 🙂 |
`git commit --amend` was invoked on this commit to be force pushed so that TravisCI can do its thing.
5fc9af0
to
7dcc30e
Compare
I've done the |
Thanks Stephen. |
I've been using rascam in a long-lived process that periodically creates
and drops a SimpleCamera (that has an encapsulated SeriousCamera)
periodically or on demand. The process mainly hosts an actix-web
HttpServer and periodically saves an image from the raspberry pi camera,
or serves a live feed from it through the front-end.
Eventually, creating SimpleCamera fails with the following error
message:
It seems that rascam has a memory leak in GPU memory. Upon examination,
I've discovered some pointers to mmal objects created with mmal_*_create
that were never freed with mmal_*_destroy.
This commit addresses this issue by cleaning up mmal objects which
should prevent (or at least reduce) GPU memory leaks.
Note that I've been checking the GPU memory of a Raspberry Pi 3B with
the following commands:
After applying this commit, the periodic usage of SimpleCamera appears
to not leak the GPU memory.
Signed-off-by: Stephen Seo seo.disparate@gmail.com