ZM & RAM?

Support and queries relating to all previous versions of ZoneMinder
Locked
zherebet
Posts: 31
Joined: Sun Jul 31, 2005 7:38 pm

ZM & RAM?

Post by zherebet »

Hey Everyone,

Just quite curious about how RAM is used by ZM - I have one camera running at 640x480, color depth turned down slightly and frame rate at around 13 fps. I have 512 MB of ram, about half of that is free before I start ZM. When I start ZM with this one monitor, ram starts slowly decreasing. It decreases down from 256 MB free to about 5-10 MB free and just hangs there (going up and down but never down to zero).

Is this normal? Is it supposed to "eat up" the ram? I've had instances where I ran 9 cameras and one 512 ram chip was not enough (320x240 @ 5 fps - system crashed after eating up the memory). So I added another 512 chip - but the same thing happened, the memory was eaten up (but this time it didn't crash).

Can anyone shed light?
Regards,

Ilya Zherebetskiy
jameswilson
Posts: 5111
Joined: Wed Jun 08, 2005 8:07 pm
Location: Midlands UK

Post by jameswilson »

usually the ram is used but as a cache. If you run top and have a look at what memory is doing what you will see that out of your 512 Meg you have 40meg free and 300meg cache on the swap.

James
zherebet
Posts: 31
Joined: Sun Jul 31, 2005 7:38 pm

Post by zherebet »

Here's what I see in top on the 9 cam system:

Mem: 1034712k total, 1020948k used, 13764k free, 19116k buffers
Swap: 996020k total, 0k used, 996020k free, 761924k cached

Here's what I see in top on the 4 cam system:


Mem: 515972k total, 511200k used, 4772k free, 12664k buffers
Swap: 1020088k total, 63964k used, 956124k free, 217028k cached

Here's what I see in top on a 1 cam system (AMD based - its' now showing swap for some reason - but its there!)

Mem: 482292k total, 476348k used, 5944k free, 5520k buffers
Swap: 0k total, 0k used, 0k free, 370440k cached


In other words - my free memory, no matter how many cams I run, usually drains down to somewhere between 4 MB and 10-12 MB.

I understand that it cache's a lot - 200 MB worth for 1 camera? Does that sound right?
Regards,

Ilya Zherebetskiy
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

I think you'll find that a lot of the ram goes into caching the filesystem structures so as more files are accessed or created this amount increases. It monitors how much is free so it never uses all of it up but will grab any unused memory and use that.

You could try a test and instead of running ZM, run a script that accesses random files in the filesystem and see if that replicates the behaviour.

Phil
jameswilson
Posts: 5111
Joined: Wed Jun 08, 2005 8:07 pm
Location: Midlands UK

Post by jameswilson »

I alwasy thought that the cache part of swap in top showed where ram shown as 'used' was acvtually being used. If you do something memory intensive your free ram will drop a bit but so will the swap cache. From what i have read about linux, its not actually a swap cache but thuis ram is being used by linux to casche the hard drives, and as such linux will use all the ram it can and move allocated ram to different processes as required. If your zm box actually needed some more real ram, linux would lower the cache amount and give ram to the app that needed it.

Thats what i understood anyway i may be wrong (only been on linux since june)

James
Locked