vladimirvivien / go4vl

A Go library for working with the Video for Linux API (V4L2).
MIT License
245 stars 45 forks source link

Fix for memory leak in stream loop #26

Closed vladimirvivien closed 2 years ago

vladimirvivien commented 2 years ago

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