Possible Memory Issue with ZMS in 1.37.40

Current Development version likely to have breaking changes
Post Reply
jaredhallen
Posts: 2
Joined: Fri Jun 30, 2023 9:34 pm

Possible Memory Issue with ZMS in 1.37.40

Post by jaredhallen »

Hello. I'm new to Zoneminder, so please bear with me. I've been trying things out this week, and was initially running 1.36, but then upgraded to 1.37.40 in order to use some of the new features. After that, I started noticing problems with video playback. If I go to the events page and play an event from there, it will begin playing fine, but then well freeze up after a minute or so. I did some digging around, and it seems like the ZMS processes that get spawned start chewing up system memory, and don't go away/die either. Eventually all the system memory (40GB) gets chewed up and the web server crashes. I tried changing out from apache2 to nginx, and the issue remains. I can put in a bug report if that'd be helpful. Not sure if anyone else is seeing this, or if it's just me?

Thanks!
JHA
jrtaylor71
Posts: 16
Joined: Mon Oct 10, 2022 3:15 pm

Re: Possible Memory Issue with ZMS in 1.37.40

Post by jrtaylor71 »

I am seeing a similar problem with 1.37.40 but only when a camera is offline. I had 2 IP camera's damaged from a storm and all the memory got used up and the cpu's were running at 95%. Apache2 had been crashing to. I disabled both camera's in the configuration, rebooted and the problem stopped.

Here is how my camera's are configured. Make sure you are not dual decoding and using Y channel analysis will reduce cpu load greatly.

Code: Select all

*************************** 2. row ***************************
                        Id: 2
                      Name: EntrywayBasement
                   Deleted: 0
                     Notes: 
                  ServerId: 0
                 StorageId: 1
            ManufacturerId: NULL
                   ModelId: NULL
                      Type: Ffmpeg
                  Function: Monitor
                 Capturing: Always
                 Analysing: Always
            AnalysisSource: Primary
             AnalysisImage: YChannel
                 Recording: Always
                   Enabled: 0
           DecodingEnabled: 1
                  Decoding: Always
              JanusEnabled: 0
         JanusAudioEnabled: 0
    Janus_Profile_Override: 
   Janus_Use_RTSP_Restream: 0
           Janus_RTSP_User: NULL
Janus_RTSP_Session_Timeout: 0
            LinkedMonitors: NULL
                  Triggers: 
         EventStartCommand: 
           EventEndCommand: 
                 ONVIF_URL: 
            ONVIF_Username: 
            ONVIF_Password: 
             ONVIF_Options: 
      ONVIF_Event_Listener: 0
          ONVIF_Alarm_Text: 
           use_Amcrest_API: 0
                    Device: 
                   Channel: 0
                    Format: 0
            V4LMultiBuffer: NULL
       V4LCapturesPerFrame: 1
                  Protocol: NULL
                    Method: rtpRtsp
                      Host: NULL
                      Port: 
                   SubPath: 
                      Path: rtsp://192.168.55.66:554/11
                SecondPath: NULL
                   Options: NULL
                      User: NULL
                      Pass: NULL
                     Width: 1920
                    Height: 1080
                   Colours: 4
                   Palette: 0
               Orientation: ROTATE_0
             Deinterlacing: 0
                   Decoder: libx264
        DecoderHWAccelName: NULL
      DecoderHWAccelDevice: NULL
                 SaveJPEGs: 0
               VideoWriter: 2
               OutputCodec: 0
                   Encoder: libx264
           OutputContainer: mp4
         EncoderParameters: 
               RecordAudio: 1
           RecordingSource: Primary
              RTSPDescribe: 0
                Brightness: -1
                  Contrast: -1
                       Hue: -1
                    Colour: -1
               EventPrefix: Event-
               LabelFormat: 
                    LabelX: 0
                    LabelY: 0
                 LabelSize: 2
          ImageBufferCount: 3
       MaxImageBufferCount: 121
               WarmupCount: 0
             PreEventCount: 5
            PostEventCount: 5
        StreamReplayBuffer: 0
           AlarmFrameCount: 3
             SectionLength: 300
         SectionLengthWarn: 0
          MinSectionLength: 10
                 FrameSkip: 0
           MotionFrameSkip: 0
          AnalysisFPSLimit: 2.00
       AnalysisUpdateDelay: 0
                    MaxFPS: NULL
               AlarmMaxFPS: NULL
         FPSReportInterval: 100
              RefBlendPerc: 6
         AlarmRefBlendPerc: 6
              Controllable: 0
                 ControlId: NULL
             ControlDevice: MainProfileToken
            ControlAddress: NULL
           AutoStopTimeout: NULL
               TrackMotion: 0
                TrackDelay: NULL
            ReturnLocation: -1
               ReturnDelay: NULL
           ModectDuringPTZ: 0
               DefaultRate: 100
              DefaultScale: 0
              DefaultCodec: auto
         SignalCheckPoints: 0
         SignalCheckColour: #0000be
                 WebColour: #867aae
                      Exif: 0
                  Sequence: 2
                 ZoneCount: 1
                   Refresh: NULL
                  Latitude: NULL
                 Longitude: NULL
                RTSPServer: 0
            RTSPStreamName: 
                Importance: Normal
              MQTT_Enabled: 0
        MQTT_Subscriptions: 
jaredhallen
Posts: 2
Joined: Fri Jun 30, 2023 9:34 pm

Re: Possible Memory Issue with ZMS in 1.37.40

Post by jaredhallen »

Thanks for the reply. It seems I can confirm what you're seeing. I also had a couple cameras offline. Deleting them and rebooting seems to have eliminated the issue. I suppose I'll re-add the offline cams and see if I can re-create. If so I'll put in a bug report.
jrtaylor71
Posts: 16
Joined: Mon Oct 10, 2022 3:15 pm

Re: Possible Memory Issue with ZMS in 1.37.40

Post by jrtaylor71 »

Here is what I am seeing in the logs when a camera is offline. This continues until all the memory is used up along with the swap memory.

Code: Select all

Jul 14 16:02:39 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00001.jpg, continuing]
Jul 14 16:02:39 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00002.jpg, continuing]
Jul 14 16:02:39 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00003.jpg, continuing]
Jul 14 16:02:40 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00004.jpg, continuing]
Jul 14 16:02:40 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00005.jpg, continuing]
Jul 14 16:02:40 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00006.jpg, continuing]
Jul 14 16:02:40 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00007.jpg, continuing]
Jul 14 16:02:41 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00008.jpg, continuing]
Jul 14 16:02:42 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00009.jpg, continuing]
Jul 14 16:02:45 nvr zms_m6[2719]: ERR [zms_m6] [Couldn't get lock on /var/tmp/zm/zmswap-m6/zmswap-q379274/zmswap-i00000.jpg, continuing]
User avatar
iconnor
Posts: 3197
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Possible Memory Issue with ZMS in 1.37.40

Post by iconnor »

That warning log is new as of a few days ago. zms is creating jpeg images and writing them to disk so that if you pause and want to rewind, you can. Problem is that creating jpegs is actually very cpu intensive. Turn this feature off by setting StreamReplayBuffer to 0 on the misc tab of the monitor.

This should have nothing to do with the monitor being offline though.
jrtaylor71
Posts: 16
Joined: Mon Oct 10, 2022 3:15 pm

Re: Possible Memory Issue with ZMS in 1.37.40

Post by jrtaylor71 »

Ok I will try that. Here is some more info for you. I had left this monitor open on a PC in my shop and forgot about it. The power went out causing the monitor to go offline along with a few others. This caused the server memory to fill up and CPU go to almost 100% so I rebooted the server as right now I have ZM to not start on startup. When I logged into the server and started ZM this is what I got and this was from a camera that was still offline.

Long story short if you access a camera that is offline it causes the memory to completely fill up.

Let me know if you need and testing or log files.
jrtaylor71
Posts: 16
Joined: Mon Oct 10, 2022 3:15 pm

Re: Possible Memory Issue with ZMS in 1.37.40

Post by jrtaylor71 »

Was already set to 0. See camera config I posted above.

Code: Select all

StreamReplayBuffer: 0
dougmccrary
Posts: 1322
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: Possible Memory Issue with ZMS in 1.37.40

Post by dougmccrary »

I've seen that, but looks to me like it's fixed in 1.37.41
Post Reply