Good Afternoon,
I am running a python program where it is required for me to capture a video stream for a short amount of time (2-40 seconds) and then put it on hold to save energy before restarting it again later in the program when required and this happens multiple times. However, every time the video capture is created and then stopped, it has a small memory leak which after 20+ iterations will fill up the entire memory.
The camera sensor is IMX219-160, opencv 4.1.1, Python 3.6.9, Jetson ‘R32 (release), REVISION: 3.1, GCID: 18186506, BOARD: t210ref, EABI: aarch64’
I have attached a small script to reproduce the memory leak with minimal code.
def __gstreamer_pipeline(capture_width=Constant.RGB_WIDTH, capture_height=Constant.RGB_HEIGHT,
display_width=Constant.RGB_WIDTH, display_height=Constant.RGB_HEIGHT,
framerate=Constant.RGB_FPS, flip_method=0):
return (
"nvarguscamerasrc ! "
"video/x-raw(memory:NVMM), "
"width=(int)%d, height=(int)%d, "
"format=(string)NV12, framerate=(fraction)%d/1 ! "
"nvvidconv flip-method=%d ! "
"video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! "
"videoconvert ! "
"video/x-raw, format=(string)BGR ! appsink "
“wait-on-eos=false drop=true max-buffers=1”
% (
capture_width,
capture_height,
framerate,
flip_method,
display_width,
display_height,
)
)
def check_release_leak():
while True:
cap = cv2.VideoCapture(__gstreamer_pipeline(flip_method=0), cv2.CAP_GSTREAMER)
sleep(0.5)
cap.release()
print(“stopped”)
sleep(0.5)
Any help would be welcome.
Thank You,
Saturnin Pugnet