I wrote a script that constantly writes a lot of data on a tmpfs partition. The size of this partition is 40% of RAM. The size of the data in this partition never exceeds the 60% of the whole partition capacity. But even if in theory the setup is allright if I monitor the server during the day with "free -m" I notice that the free RAM constantly drops to the point that the servers starts swapping, the out of memory is reached and the system crashes.
This is my /etc/fstab entry:
tmpfs /home/tmpdata tmpfs defaults,size=40%,gid=1000,uid=1000,mode=0777 0 0
My system is Debian 8.3 on a dedicated server with 64GB. I suspect that the RAM never gets freed when the data changes, for example when a file is being deleted.
This is the free -m double output:
root@xxxx:~# free -m
total used free shared buffers cached
Mem: 64454 41792 22661 3884 280 39268
-/+ buffers/cache: 2243 62210
Swap: 1021 0 1021
root@xxxx:~# free -m
total used free shared buffers cached
Mem: 64454 41827 22626 3879 280 39272
-/+ buffers/cache: 2274 62179
Swap: 1021 0 1021
and /cat/meminfo:
root@xxx:~# cat /proc/meminfo
MemTotal: 66001072 kB
MemFree: 20659152 kB
MemAvailable: 59740116 kB
Buffers: 288776 kB
Cached: 42705492 kB
SwapCached: 0 kB
Active: 11959248 kB
Inactive: 32386536 kB
Active(anon): 4179904 kB
Inactive(anon): 1263864 kB
Active(file): 7779344 kB
Inactive(file): 31122672 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 1046520 kB
SwapFree: 1046520 kB
Dirty: 288 kB
Writeback: 8 kB
AnonPages: 1353516 kB
Mapped: 120216 kB
Shmem: 4091776 kB
Slab: 483428 kB
SReclaimable: 300772 kB
SUnreclaim: 182656 kB
KernelStack: 7696 kB
PageTables: 40440 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 34047056 kB
Committed_AS: 7712460 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 389912 kB
VmallocChunk: 34359130252 kB
HardwareCorrupted: 0 kB
DirectMap4k: 6924 kB
DirectMap2M: 2056192 kB
DirectMap1G: 67108864 kB
and cat /proc/swaps:
root@xxxx:~# cat /proc/swaps
Filename Type Size Used Priority
/dev/sdb4 partition 523260 0 -1
/dev/sda4 partition 523260 0 -2
free -msuch that we can see if the numbers indicate any problem. On a properly configured system, the free memory is usually always close to 0, and free swap space is never close to 0. – kasperd Feb 26 '16 at 13:28free -mandcat /proc/meminfo | grep -i memfreegive two different results. Which is the right one? – Viktor Joras Feb 26 '16 at 14:41free -mis just formatting the numbers from/proc/meminfo. As long as you read the numbers correctly, you will get the same numbers from both locations. – kasperd Feb 26 '16 at 14:4222626indicates that approximately 22GB of your memory is free. That's a reasonable amount of free memory for a machine with 64GB. If you look in/proc/meminfoyou should find approximatelyMemFree: 23169024 kBif you were looking at the same time. Of the 41GB of memory in use, most of it is used for cache. The amount used for caching is41827-2274or62179-22626or280+39272, which works out to about 39GB. So you have plenty of memory for caching. – kasperd Feb 26 '16 at 14:49free -malways look similar to what you posted, then it indicates that you have plenty of memory for your workload. You'd probably experience a minor slowdown if you cut your memory in half. – kasperd Feb 26 '16 at 14:50free -m, your server is not swapping. The output fromfree -mjust before you start seeing problems and while you have problems, would be helpful. The amount of swap space allocated seems a bit small. You only have 1GB of swap allocated for a machine with 64GB of physical memory. Depending on your workload, that might be a problem, though it was not a problem at the time where you ranfree -m. – kasperd Feb 26 '16 at 14:53cat /proc/swapssay? – kasperd Feb 26 '16 at 15:01cat /proc/swapsin the question. – Viktor Joras Feb 26 '16 at 15:09topcommand running through ssh as well, such that you can see whattopwas outputting moments before the server became unresponsive. – kasperd Feb 26 '16 at 15:12free -mall of a sudden said free memory was 30GB and one instant before it was near 300MB whilecat /proc/swapsshowed an increasing swap usage of all 2x500MB swaps. When all of the swap space has been filled the system got unresponsive, the ssh shell got stuck and I had to hard reboot. Now my question is why all of a sudden the RAM memory has been freed while the swap has been havily used. – Viktor Joras Feb 27 '16 at 07:28vmstat 1to a file. – John Mahowald Feb 28 '16 at 00:43