After tweaking the capture image size of some of the IP cameras connected to our ZoneMinder installation we started to get the following error in the ZoneMinder log right after launching a viewer to watch the camera’s video stream:
Got unexpected memory map file size 36865192, expected 9217192
Googling for this error took us to this blog post:
http://jared-oberhaus-tech-notes.blogspot.com/2011/12/im-trying-to-capture-video-from-device.html
Which in turn took us to the ZoneMinder FAQ.
The recommendation is to increase the setting /proc/sys/kernel/shmmaxsize so ZoneMinder has enough memory to memory-map the files it needs during streaming.
However, upon checking our /proc/sys/kernel/shmmaxsize setting we found that it had pretty high setting (the recommended [in the ZoneMinder FAQ] 536870912, for 128 MB of maximum shared memory allocatable at a time), because we had run into the issue before and tried to fix it by following the recommendation in the ZoneMinder FAQ. In addition, the error message indicates that it expects a file with a size that is smaller than it currently has, so increasing the /proc/sys/kernel/shmmaxsize setting would not have fixed the problem.
It turns out that ZoneMinder had created the memory-mapped file for a specific capture image size:
$ ls -l /dev/shm/ total 90016 -rw------- 1 www-data www-data 36865192 Apr 9 08:24 zm.mmap.6 [...]
And when we changed the capture image size to a smaller resolution, the required size of the memory-map filed decreased. However, because ZoneMinder had not been restarted, the memory-mapped file had not been recreated, and it still had the size that ZoneMinder allocated for the original, higher resolution video capture.
Re-starting ZoneMinder caused the memory-mapped file to be recreated, now with the correct size for the new (smaller) capture image size:
$ ls -l /dev/shm/ total 63016 -rw------- 1 www-data www-data 9217192 Apr 9 08:47 zm cialis online ohne rezept.mmap.6 [...]
After this, ZoneMinder did not generate the error anymore.
Update 20130415:
We increased the capture image size of one of the ZoneMinder monitors and received again the “Got unexpected memory map file size …” message, this time indicating that the size of the file is smaller than expected. This makes sense and shows that the issue has nothing to do with the configured value in /proc/sys/kernel/shmmaxsize but with a memory-mapped filed created by ZoneMinder that is not recreated when the size of the image capture is changed. This should be considered a bug in ZoneMinder, in our opinion. We are running ZoneMinder 1.25.0.