iEvgeny / cctv-viewer

CCTV Viewer - viewer and mounter video streams.
GNU General Public License v3.0
135 stars 19 forks source link

Memory leaks #11

Closed kintoxo closed 2 years ago

kintoxo commented 3 years ago
# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  17260 watchman 16.5 /snap/cctv-viewer/700/usr/bin/cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  17260 watchman 16.6 /snap/cctv-viewer/700/usr/bin/cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  17260 watchman 21.6 /snap/cctv-viewer/700/usr/bin/cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  17260 watchman 52.0 /snap/cctv-viewer/700/usr/bin/cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  17260 watchman 53.9 /snap/cctv-viewer/700/usr/bin/cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  17260 watchman 72.8 /snap/cctv-viewer/700/usr/bin/cctv-viewer

The RAM consumption of the cctv-viewer process is constantly growing until it fills all the free memory and swap.

iEvgeny commented 3 years ago

Hi! Under what circumstances does the problem described above occur? Does the problem recur after a complete deletion of the configuration in ~/snap/cctv-viewer/current/.config/CCTV Viewer/CCTV Viewer.conf? Have you tried installing CCTV Viewer from my PPA https://launchpad.net/~ievgeny/+archive/ubuntu/cctv-viewer?

kintoxo commented 3 years ago

I deleted the file ~/snap/cctv-viewer/current/.config/CCTV Viewer/CCTV Viewer.conf, and restart cctv-viewer. But Nothing has changed.

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  23586 watchman  6.2 /snap/cctv-viewer/700/usr/bin/cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  23586 watchman  6.8 /snap/cctv-viewer/700/usr/bin/cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  23586 watchman  7.1 /snap/cctv-viewer/700/usr/bin/cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  23586 watchman  9.0 /snap/cctv-viewer/700/usr/bin/cctv-viewer

I using a fresh install of Ubuntu 20.04 Desktop x64. And used the installation cctv-viewer from a SNAP packages. Today I will try to install from PPA and write later about the result. Thanks for the quick feedback and help.

kintoxo commented 3 years ago

I remove SNAP version, and install from PPA https://launchpad.net/~ievgeny/+archive/ubuntu/cctv-viewer and nothing changes.

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  29648 watchman  7.6 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  29648 watchman  9.3 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  29648 watchman 16.8 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  29648 watchman 17.3 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  29648 watchman 47.3 cctv-viewer

When I run the cctv-viewer from the command line as a user, I get the following messages in the console.

$ cctv-viewer
QML debugging is enabled. Only use this in a safe environment.
using null output device, none available
[rtsp @ 0x7efdd40075c0] max delay reached. need to consume packet
[rtsp @ 0x7efdd40075c0] RTP: missed 7 packets
[h264 @ 0x7efdd400a0c0] error while decoding MB 15 32, bytestream -11
[h264 @ 0x7efdd400a0c0] concealing 210 DC, 210 AC, 210 MV errors in I frame
using null output device, none available
using null output device, none available
[rtsp @ 0x7efdd0007dc0] max delay reached. need to consume packet
[rtsp @ 0x7efdd0007dc0] RTP: missed 12 packets
[h264 @ 0x7efdd006e200] error while decoding MB 15 7, bytestream -13
[h264 @ 0x7efdd006e200] concealing 1310 DC, 1310 AC, 1310 MV errors in P frame
using null output device, none available
using null output device, none available
[rtsp @ 0x7efddc007dc0] max delay reached. need to consume packet
[rtsp @ 0x7efddc007dc0] RTP: missed 7 packets
using null output device, none available
using null output device, none available
[h264 @ 0x7efdd406b100] error while decoding MB 15 32, bytestream -11
[h264 @ 0x7efdd406b100] concealing 210 DC, 210 AC, 210 MV errors in I frame
using null output device, none available
[rtsp @ 0x7efdd8007140] max delay reached. need to consume packet
[rtsp @ 0x7efdd8007140] RTP: missed 8 packets
using null output device, none available
[h264 @ 0x7efdd806c580] error while decoding MB 28 32, bytestream -22
[h264 @ 0x7efdd806c580] concealing 197 DC, 197 AC, 197 MV errors in I frame
[rtsp @ 0x7efddc007dc0] max delay reached. need to consume packet
[rtsp @ 0x7efddc007dc0] RTP: missed 22 packets
[h264 @ 0x7efddc06ac80] cabac decode of qscale diff failed at 29 32
[h264 @ 0x7efddc06ac80] error while decoding MB 29 32, bytestream -6
[h264 @ 0x7efddc06ac80] concealing 196 DC, 196 AC, 196 MV errors in I frame
[h264 @ 0x7efddc06ac80] Increasing reorder buffer to 1
[rtsp @ 0x7efdd0007dc0] max delay reached. need to consume packet
[rtsp @ 0x7efdd0007dc0] RTP: missed 23 packets
[h264 @ 0x7efdd006e200] error while decoding MB 25 30, bytestream -34
[h264 @ 0x7efdd006e200] concealing 288 DC, 288 AC, 288 MV errors in I frame
[rtsp @ 0x7efdd0007dc0] max delay reached. need to consume packet
[rtsp @ 0x7efdd0007dc0] RTP: missed 5 packets
[h264 @ 0x7efdd006e200] left block unavailable for requested intra mode
[h264 @ 0x7efdd006e200] error while decoding MB 0 33, bytestream 415
[h264 @ 0x7efdd006e200] concealing 181 DC, 181 AC, 181 MV errors in I frame
[rtsp @ 0x7efdd0007dc0] max delay reached. need to consume packet
[rtsp @ 0x7efdd0007dc0] RTP: missed 3 packets
[h264 @ 0x7efdd006e200] error while decoding MB 28 34, bytestream -48
[h264 @ 0x7efdd006e200] concealing 109 DC, 109 AC, 109 MV errors in I frame

This all with my ~/.config/CCTV Viewer/CCTV Viewer.conf. I use rtsp stream from Dahua video recorder and a computer with a cctv-viewer in the same local network. Ping statistics from computer to video recorder: with 64 bytes package size

90 packets transmitted, 90 received, 0% packet loss, time 91040ms
rtt min/avg/max/mdev = 0.103/0.468/2.256/0.250 ms

with 1400 bytes package size

159 packets transmitted, 159 received, 0% packet loss, time 161457ms
rtt min/avg/max/mdev = 0.177/0.516/1.866/0.208 ms
iEvgeny commented 3 years ago

Ok. I will ask you to follow these instructions exactly:

  1. Close the aplication
  2. Delete the configuration file
  3. Run the application
  4. Let me know if you see demo video streams image
iEvgeny commented 3 years ago

This is not a memory leak issue, but for the RTSP protocol you will need to additionally specify the -rtsp_transport tcp option in the "AVFormat options" field in the sidebar for each viewport.

kintoxo commented 3 years ago

Ok. I will ask you to follow these instructions exactly:

  1. Close the aplication
  2. Delete the configuration file
  3. Run the application
  4. Let me know if you see demo video streams ...

I did everything according to your instructions. 1) Closed the application. 2) Deleted the config file. 3) Launched the application. 4) Demo video streams have appeared.

cctv-viewer-default

But the application continues to "devour" the computer's RAM even when displaying demo video streams.

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  12816 watchman  4.9 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  12816 watchman  5.1 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
  12816 watchman  9.3 cctv-viewer

For clarity, I filmed a short video of how it happens in real time when displaying demo video streams (video in GIF format). 2021-05-04 14-11-24-1

kintoxo commented 3 years ago

This is not a memory leak issue, but for the RTSP protocol you will need to additionally specify the -rtsp_transport tcp option in the "AVFormat options" field in the sidebar for each viewport.

Thank you for your comment. I added -rtsp_transport tcp to the" AVFormat options" of each viewport.

This helped to fix the errors that were displayed when the application was launched from the console. And you are right, it didn’t help the application “eating” RAM.

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
   4146 watchman  8.1 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
   4146 watchman  9.1 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
   4146 watchman  9.9 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
   4146 watchman 12.0 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
   4758 watchman 36.0 cctv-viewer

# ps -o pid,user,%mem,command ax | sort -b -k3 -r |grep cctv
   8415 watchman 62.6 cctv-viewer
iEvgeny commented 3 years ago

This is very strange... What is the version of the operating system and its architecture?

You may also need to send me the debug output. To do this, run the CCTV Viewer as follows: export VERBOSE_LEVEL=3 && cctv-viewer 2>&1 | tee debug.log

Please be careful. The output may contain sensitive data. Use https://gist.github.com/ to post the output or email me the file.

kintoxo commented 3 years ago

This is very strange... What is the version of the operating system and its architecture?

You may also need to send me the debug output. To do this, run the CCTV Viewer as follows: export VERBOSE_LEVEL=3 && cctv-viewer 2>&1 | tee debug.log

Please be careful. The output may contain sensitive data. Use https://gist.github.com/ to post the output or email me the file.

I am using ubuntu 20.04 (gnome) x64 with the latest installed updates.

# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal
# uname -a
Linux user-Standard-PC-i440FX-PIIX-1996 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Debug log from application with default config export VERBOSE_LEVEL=3 && cctv-viewer 2>&1 | tee debug.log: https://gist.githubusercontent.com/kintoxo/d12534a40c0730ed175ddada61dc1abc/raw/a8bc4903aaa4261a5cb4ba57e1367c7018e7e72b/debug.log

I also attach the strace log strace cctv-viewer 2>&1 | tee debug-strace.log https://gist.githubusercontent.com/kintoxo/31c23ab9df6b3cacc278ee9147415caa/raw/9362e08efd1b255f97aedd30064caa629329ba7d/debug-strace.log

iEvgeny commented 3 years ago

Thank you for the information provided! So far I have not been able to reproduce the problem and I need some time to look into it.

Billysredhat commented 2 years ago

Was this issue ever resolved? I am having a very similar issue with the memory usage growing until the app crashes and logs "kernel out of memory killed process XXX (cctv-viewer).

iEvgeny commented 2 years ago

Unfortunately, I cannot confirm the problem on my side. I plan to investigate this issue in detail while working on hardware acceleration.

iEvgeny commented 2 years ago

Made some changes to the code. Please test the application for memory leaks.

Billysredhat commented 2 years ago

Thank You for making changes and addressing this issue. I have had a couple computers running for about 5 days now and the update does seem to have helped the steady building of memory use.

This may be a stupid question but how do I tell if the program is the most updated version. I use your ppa, to get around snap issues with our firewall, and I can. It seem to figure out how to verify that the new update was installed unless I install it manually.

iEvgeny commented 2 years ago

I don't really understand your question. But in any case you need to use the features of your package manager. The PPA version is built from the GitHub repository automatically every day.

kintoxo commented 2 years ago

Made some changes to the code. Please test the application for memory leaks.

I have checked the operation of cctv-viewer v0.1.8-alpha for 7 days and do not observe any more memory leaks. I no longer need a crutch to restart the cctv viewer every three hours. Thank you Evgeny for this software product and fixing the memory leak problem.