High Ram usage

Previous development branch now released as 1.36
phgerin
Posts: 11
Joined: Tue Feb 09, 2021 10:28 am

High Ram usage

Post by phgerin »

Hello,

Since version 1.35.18 I have very high memory usage. The ram usage just doubled.
I have 19 cams, all HD resolution, same configuration.
The activity monitor shows 19 zmc processes. The first une use 1,5Gb of ram, the last one 179Mb of ram.
Bug ?

Thanks !
nrbell
Posts: 30
Joined: Mon Jun 04, 2018 1:14 pm

Re: High Ram usage

Post by nrbell »

Have you read this post about the updates from @iconnor?

It looks like shared memory is no longer used to communicate between zmc and zma. This means that most of what you have allocated for ImageBufferCount is just wasted. It is recommended that you set it to 2.
phgerin
Posts: 11
Joined: Tue Feb 09, 2021 10:28 am

Re: High Ram usage

Post by phgerin »

Yes, thanks. Everything is set to '2.

Same config for all the cams (and same cam model), some zmc process are using more than 1gb of ram, some 156 mb of ram.
Why ?
GabrielleHunter
Posts: 1
Joined: Wed Feb 10, 2021 8:18 am

Re: High Ram usage

Post by GabrielleHunter »

The same problem. I have to roll back to the old version, can it be a bag??
Last edited by GabrielleHunter on Thu Feb 11, 2021 6:48 pm, edited 1 time in total.
nrbell
Posts: 30
Joined: Mon Jun 04, 2018 1:14 pm

Re: High Ram usage

Post by nrbell »

I answered before I had done much testing. I see it now. Some zmc processes are using enormous amounts of memory, even in Monitor mode.

Some monitors use a reasonable amount and some use a stupid amount. I cannot figure out what causes the difference.
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: High Ram usage

Post by Magic919 »

It might be worth mentioning it in the referenced thread.
-
nrbell
Posts: 30
Joined: Mon Jun 04, 2018 1:14 pm

Re: High Ram usage

Post by nrbell »

That thread is specifically for new features in 1.35.*. I don't think that it is the appropriate place for this discussion. I'm hoping that this thread will get some attention.

If I can get some kind of handle on what is going on, I will make an issue post on the ZoneMinder github.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: High Ram usage

Post by knight-of-ni »

Since this issue is regarding a new feature in 1.35, that's the perfect place to mention it. Either that or in our Slack channel where you can get up to the minute updates of our activity.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
nrbell
Posts: 30
Joined: Mon Jun 04, 2018 1:14 pm

Re: High Ram usage

Post by nrbell »

I was able to get my cameras working thanks to some help from the folks on the Slack channel.

Apparently, zmc is queuing all frames in between keyframes. My misbehaving cameras were set to use H.264+ encoding which @iconnor says has a very high keyframe interval. Once I turned off H.264+ memory usage went to something reasonable. I should also note that I am using an I-Frame interval equal to my frame rate, so the keyframe interval is not huge.
tomcat84
Posts: 39
Joined: Fri Jul 03, 2020 11:24 pm

Re: High Ram usage

Post by tomcat84 »

Its not only higher ram usage. I also get higher CPU usage for each zmc. Nearly 20-30% more. Its unusuable now. Any suggestions?
Is there a way to go back to 1.35.16?
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: High Ram usage

Post by Magic919 »

Suggestions are -

Update again as there is still work being committed.

Reduce frame rate and lower keyframe interval on the cameras. The earlier poster is now using one keyframe a second, for example.

Downgrading might be possible, depends on the install method.
-
tomcat84
Posts: 39
Joined: Fri Jul 03, 2020 11:24 pm

Re: High Ram usage

Post by tomcat84 »

Tnx for your suggestions. I updated the ubuntu system with apt upgrade just 30 mins ago so no help for now from new updates :(
I already had keyframeintervall on 3 if I put it on 1 it cpu usage ingrease again. I put it on 2 now but its not realy helping.
My framrate is 10.
I also getting

Code: Select all

2021-02-10 21:38:39	zmc_m1		12996	WAR	Hit end of packetqueue before satisfying pre_event_count. Needed 33 more video frames]	zm_packetqueue.cpp	521
2021-02-10 21:38:37	zmc_m7		13996	WAR	Hit end of packetqueue before satisfying pre_event_count. Needed 33 more video frames]
Now with Image Buffer Size (frames) 50 and Pre Event Image Count 35 what was working bevore the update.
nrbell
Posts: 30
Joined: Mon Jun 04, 2018 1:14 pm

Re: High Ram usage

Post by nrbell »

I've definitely been able to downgrade from 1.35.18 to 1.35.16 without a problem. The only problem I have had in the past is finding the packages. If your system keeps old packages around then they should be in /var/cache/apt/archives.

If you are running motion detection then each zmc should be seeing higher usage since the functionality of zma has been folded into zmc. This doesn't account for all of it though. I'm running six cameras on an i7-4770 and the CPU usage is bouncing between 70-90%. This is definitely not usable.
tomcat84
Posts: 39
Joined: Fri Jul 03, 2020 11:24 pm

Re: High Ram usage

Post by tomcat84 »

I also just took the risk and downgraded.
For now I see no problems.
You get the older packages from here:
https://launchpad.net/~iconnor/+archive ... tate=built
Version 1.35.16~20210122121212-bionic was the last runing normal for me.
Then:

Code: Select all

sudo dpkg -i zoneminder_1.35.16~20210122121212-bionic_arm64.deb
dpkg: Warnung: Version 1.35.18~20210210132142-bionic des Paketes zoneminder wird durch ältere Version 1.35.16~20210122121212-bionic ersetzt
(Lese Datenbank ... 162200 Dateien und Verzeichnisse sind derzeit installiert.)
Vorbereitung zum Entpacken von zoneminder_1.35.16~20210122121212-bionic_arm64.deb ...
Entpacken von zoneminder (1.35.16~20210122121212-bionic) über (1.35.18~20210210132142-bionic) ...
zoneminder (1.35.16~20210122121212-bionic) wird eingerichtet ...
Detected db service is mysql.service
Updating permissions for user zmuser@localhost

Initiating database upgrade to version 1.35.16 from version 1.35.18

Upgrading database to version 1.35.16
Loading config from DBNo option 'ZM_MIN_RTSP_PORT' found, removing.
 219 entries
Saving config to DB 219 entries

Database upgrade to version 1.35.16 successful.


Freshening configuration in database
Migratings passwords, if any...
Loading config from DB 219 entries
Saving config to DB 219 entries
Done Updating; starting ZoneMinder.
Unsafe symlinks encountered in /var/cache/zoneminder/cache, refusing.
Trigger für man-db (2.8.3-2ubuntu0.1) werden verarbeitet ...
So the only "error" was Loading config from DBNo option 'ZM_MIN_RTSP_PORT' found, removing.
Finaly a sudo apt-mark hold zoneminder to prevent such a trouble again :twisted:

Im using an AI based object detecion to trigger events not the zoneminder motion detection. So higher CPU of zmc must have an other reason in my case.
turbokongen
Posts: 1
Joined: Sun Feb 28, 2021 1:40 pm

Re: High Ram usage

Post by turbokongen »

In my case the "fix" was to lower the keyframes at the camera, and set image buffer in zm to 2.
Each zmc process went from 3,5gb to 500mb🤨
Locked