From the documentation-
What does a 'Can't shmget: Invalid argument' error in my logs mean? and my cameras won't display video at higher resolutions.
This error is discussed in the README in the following excerpt:- ...this is caused by an attempt to allocate an amount of shared memory greater than your system can handle. The size it requests is based on the following formula, ring buffer size x image width x image height x 3 (for 24 bit images) + a bit of overhead.
So, for example:
384x288 capture resolution, that makes: 110 592 pixels
in 24 bit color that's x24 = 2 654 208 bits per frame
by 80 frames ring buffer x80 = 212 336 640 bits per camera
by 4 cameras x4 = 849 346 560 bits.
Plus 10% overhead = 934 281 216 bits
That's 116 785 152 bytes, and
= 114 048 kB, respectively 111.38 MB.
If my shared memory is set to 134 217 728, which is exactly 128MB,
that means I shouldn't have any problem.
(Note that 1 byte = 8 bits and 1kbyte = 1024bytes, 1MB = 1024 kB)If for instance you were using 24bit 640x480 then this would come to about 92Mb if you are using the default buffer size of 100. If this is too large then you can either reduce the image or buffer sizes or increase the maximum amount of shared memory available. If you are using RedHat then you can get details on how to change these settings at
http://www.redhat.com/docs/manuals/data ... urces.html .
You should be able to use a similar procedure with other distributions to modify the shared memory pool without kernel recompilations though in some cases this may be necessary. Note, this error also sometimes occurs if you have an old shared memory segment lying around from a previous run that is too small. Use the ipcs and ipcrm system commands to check and remove it if necessary.'"
You can often find out how much shared memory is available by typing the following :-
cat /proc/sys/kernel/shmalland the most you can allocate in one go :-
cat /proc/sys/kernel/shmmaxTo change these values type (for example) :-
echo 134217728 >/proc/sys/kernel/shmall
echo 134217728 >/proc/sys/kernel/shmmaxBe sure to restart ZoneMinder after this. However be aware that sometimes you will only need to change the shmmax value as shmall is often large enough. Also changing these values in this way is only effective until your machine is rebooted.
To change them permanently you will need to edit /etc/sysctl.conf and add the following lines (for example) :-
kernel.shmall = 134217728
kernel.shmmax = 134217728To load these settings in the sysctl.conf file type:
sysctl -pTo check your shared memory settings type:
ipcs -lNote that with Megapixel cameras like the Axis 207mw becoming cheaper and more attractive, the above memory settings are not adequate. To get Zoneminder working with a full 1280x1024 resolution camera in full colour, increase 134217728 to, for example, 268424446
These changes will now also be set the next time your machine is restarted.
Versions 1.24.x of ZoneMinder also allows you to use an alternate method of shared memory allocation, mapped memory. This requires less configuration and can be simpler to use. Mapped memory allows you to use a special type of file as the placeholder for your memory and this file is 'mapped' into memory space for easy and fast access.
To enable mapped memory in ZoneMinder you need add add the --enable--mmap=yes switch to your configure line. By default mapped memory files are created in /dev/shm which on most distributions is a dedicated pseudo-partition containing memory formatted as a filesystem. If your system uses a different path then this can be changed in ZoneMinder in Options->paths->PATH_MAP. It uses a filesystem type called tmpfs. If you type 'df' you should see this area and the size of memory it currently allows. It is important that you do not use a disk based filesystem for your memory mapped files as this will cause memory access to be extremely slow. ZoneMinder creates files called .zm.mmap.<monitor> in the mapped memory filesystem.
Mapped memory is subject to the same limitations in terms of total memory as using more traditional shared memory but does not require any configuration per allocation or chunk. In future versions of ZoneMinder this will be the default shared memory storage method.