1

Buffers+Cached+Free = 3,588,092 (3.4G) But I still can use 10G memory (not using the swap). Is this a memory leak issue? And after doing this, the leaked memory can be back?

  1. The (human-defined) free memory is 3,588,092(let's say 3.4G) and total memory is 32G
  2. During this step, we haven't found any process that eat lots of memory via the command 'top', So we thought 3.4G free is not correct, we 100% sure free memory is at least 20G
  3. We mount our memory as a ramdisk to local, and wrote data into it, as you can see, it is 10G, and it is successful
  4. After unmount, the free memory rise to 11,959,064 how could it be?

Thanks

[root@dev001 ~]# free
             total       used       free     shared    buffers     cached
Mem:      32877844   31422864    1454980          0    1358500     774612
-/+ buffers/cache:   29289752    3588092
Swap:      1048568      67984     980584
[root@dev001 ~]# mkdir /mnt/ramdisk
[root@dev001 ~]# mount -t tmpfs -o size=10g tmpfs /mnt/ramdisk
[root@dev001 ~]# cd /mnt/ramdisk/
[root@dev001 ramdisk]# dd if=/dev/zero of=1g bs=1024 count=$((1024*1024*10))
10485760+0 records in
10485760+0 records out
10737418240 bytes (11 GB) copied, 20.0645 s, 535 MB/s
[root@dev001 ramdisk]# ls -lh
total 10G
-rw-r--r-- 1 root root 10G Jul 26 21:09 1g
[root@dev001 ramdisk]# free 
             total       used       free     shared    buffers     cached
Mem:      32877844   32630940     246904          0     792364   10901876
-/+ buffers/cache:   20936700   11941144
Swap:      1048568      67984     980584
[root@dev001 ~]# umount /mnt/ramdisk
[root@dev001 ~]# free 
             total       used       free     shared    buffers     cached
Mem:      32877844   22128348   10749496          0     792416     416160
-/+ buffers/cache:   20919772   11958072
Swap:      1048568      67984     980584
[root@dev001 ~]# free
             total       used       free     shared    buffers     cached
Mem:      32877844   22127372   10750472          0     792432     416160
-/+ buffers/cache:   20918780   11959064
Swap:      1048568      67984     980584
0

First of all, a recommendation to read http://www.linuxatemyram.com/ as it's always a help to understand Linux memory management.

Probably you should keep the idea that the interesting concepts are "available" and "not available" memory. Free memory is available. Memory used by buffers/cache might be available also but the kernel won't free that memory if there's no reason for it. When you created the 10GB ramdisk it probable freed some of those buffers or cache objects, so when the ramdisk got destroyed you got more memory free (though it always was "available"). I hope this helps to understand the memory management (but seriously, read the link above :D )

As a last note beside top you can also use slabtop to get some information about the internal memory usage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.