After each execution of the code, 150 MB of memory leaks out.
cam = cv2.VideoCapture('rtsp://admin:admin@192.168.0.64:554/Streaming/Channels/101')
ret_val, img = cam.read()
ret_val = cv2.imwrite(str(chat_id) + '.jpg',img)
cam.release()
cv2.destroyAllWindows()
Most likely this is due to OpenCV. Below is the configuration OpenCV. I'm using GStreamer, to work with the H264 stream from IP camera.
General configuration for OpenCV 3.4.1-dev =====================================
Version control: 3.4.1-54-g5b868cc
Platform:
Timestamp: 2018-03-11T16:10:52Z
Host: Linux 4.13.0-36-generic x86_64
CMake: 3.5.1
Video I/O:
DC1394: YES (ver 2.2.4)
FFMPEG: NO
avcodec: NO
avformat: NO
avutil: NO
swscale: NO
avresample: NO
GStreamer:
base: YES (ver 1.8.3)
video: YES (ver 1.8.3)
app: YES (ver 1.8.3)
riff: YES (ver 1.8.3)
pbutils: YES (ver 1.8.3)
libv4l/libv4l2: NO
v4l/v4l2: linux/videodev2.h
gPhoto2: NO