Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU)
Jetson Nano Developer Kit • Gstreamer Version
1.14.5 • Opencv Version
4.7.0 • Python Version
3.6.9 • JetPack Version (valid for Jetson only)
4.6 • Issue Type( questions, new requirements, bugs)
Possible memory leak • How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
Minimal python script:
def mem_available_mb():
with open('/proc/meminfo') as file:
mem_available_in_kb = None
mem_total_in_kb = None
for line in file:
if 'MemTotal' in line:
mem_total_in_kb = int(line.split()[1])
if mem_available_in_kb is not None:
print("used:", mem_total_in_kb / 1024)
elif 'MemAvailable' in line:
mem_available_in_kb = int(line.split()[1])
break
if mem_available_in_kb is None or mem_total_in_kb is None:
continue
return mem_available_in_kb / 1024
def init_cam_streams():
cams = []
for i in range(2):
cams.append(cv2.VideoCapture(i, cv2.CAP_GSTREAMER))
return cams
if __name__ == "__main__":
file_name = "test gstreamer minimal.txt"
cams = init_cam_streams()
while True:
try:
a = mem_available_mb()
with open(file_name, "a") as f:
f.write(str(a) + "\n")
time.sleep(10)
print(len(cams))
except KeyboardInterrupt:
break
While running this script, available memory decreases with ± 1MB/min. Switching to FFMPEG backend causes the problem to disappear. Any suggestions?
Hi,
Please share the gstreamer pipeline you run in cv2.VideoCapture() for reference. And the latest release is 4.6.3. If possible, please upgrade to the release and try.
No if I leave it running for a long time (several hours) the memory keeps increasing gradually. When using top it is clear that it is the memory used by this process that is increasing.
You may first check with a second terminal running top as suggested by @mhd0425, then you should see (I’m testing that on AGX Orin running JP5, so your Nano case may differ) that gstreamer is not the culprit:
Now, using it from python, even without displaying, there is an increase of memory usage. So the issue may be in opencv python bindings or in python libs.
Note that this issue is not specific to Jetson, you may get further help from opencv forum or reporting an issue to opencv github.