[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Memory usage Debian Jessie (stable)

On 05/12/2015 04:33 AM, Fabio Tobich wrote:
You can drop the cache with this command:

sync; echo 3 > /proc/sys/vm/drop_caches

See what it does at my laptop:

root@laptop:~# free -m
                    total       used       free     shared    buffers
Mem:          7439       3029       4409        201         91       1368
-/+ buffers/cache:       1569       5870
Swap:         1906          0       1906

root@laptop:~# sync; echo 3 > /proc/sys/vm/drop_caches

root@laptop:~# free -m
                    total       used       free     shared    buffers
Mem:          7439       2001       5437        194          2        480
-/+ buffers/cache:       1518       5920
Swap:         1906          0       1906

As you can see, the cache was reduced from 1368 to 480, "freeing" more
than 1GB, but on the second line the free ammount remains the same
because, as Dan said, it ignores the cache.

$ man proc
I read:

/proc/sys/vm/drop_caches (since Linux 2.6.16)
      Writing to this file causes the kernel to drop clean caches,
      dentries, and inodes from  memory,  causing  that  memory  to
      become free.  This can be useful for memory management testing
      and performing reproducible filesystem benchmarks.  Because
      writing to this file causes the benefits of caching to be lost,
      it can degrade overall system performance.

So dropping caches may increase the amount of overhead.

2015-05-11 11:50 GMT-03:00 Dan Christensen <jdc@uwo.ca <mailto:jdc@uwo.ca>>:

    Jan-Rens Reitsma <jan.rens.reitsma@gmail.com
    <mailto:jan.rens.reitsma@gmail.com>> writes:

     > $ free -h
     >              total       used       free     shared    buffers
     > Mem:          3.7G       3.5G       182M       153M       363M
     > -/+ buffers/cache:       1.0G       2.7G
     > Swap:         7.6G         0B       7.6G
     > 3.5 GB used of 3.7 GB available memory,
     > with 2.1 GB available for caching and 182 MB free,
     > 1.0 GB of the available cache and memory is used,
     > no swap space used.

    That's not a correct interpretation of the output of "free".  What that
    output says is that 3.5GB is used, but of that, 363MB + 2.1GB = 2.5GB is
    currently being used for buffers and cache.  The memory used for buffers
    and cache can be made available very quickly, so the second line shows
    how much is used (1.0GB) and free (2.7GB) with the buffer and cache
    usage ignored.  So the real thing to take away from the above is in
    the second line:  only 1.0GB is used and 2.7GB is free.  See


If I'm right htop and the Gnome system monitor show the amount of 'Mem:' and 'Swap:' in the 'used' table.

Thanks for your remarks, since yesterday I've read about many things I didn't know yet.

Reply to: