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

Fix for memory leak in stream loop #26

Merged
merged 1 commit into from
Sep 5, 2022
Merged

Conversation

vladimirvivien
Copy link
Owner

@vladimirvivien vladimirvivien commented Sep 5, 2022

This PR fixes a memory leak reported when running the webcam example. After profiling, the leak was identified in the loop for streaming captured from from the device. Specifically, the fix simply moved the v4l2.WaitForRead function call out of the loop.

Fix

Prior to the fix, the webcam process would be killed, after about an hour of running, by the OS to prevent an OOM situation. After the fix, the followings were observed:

  • Webcam process only used 1% of memory after 5 hours of running
  • Webcam process never crashed or killed
  • After opening 8 concurrent browser tabs, receiving 30 frames of HD video per second, the memory profile stayed the same

Fixes #22

@vladimirvivien vladimirvivien merged commit 8b53b15 into main Sep 5, 2022
@vladimirvivien vladimirvivien deleted the resource-leak-refactor branch December 11, 2022 17:00
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

Successfully merging this pull request may close these issues.

Potential memory leak
1 participant