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
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:
Fixes #22