2

I have ubuntu server 14.04 installed in my server. And i have vsftpd server that provide download file test for testing purpose. my question is why if client download the ftp file, my server ram is increase rapidly in line with user download, and then it stays in same value, after user finish downloading, is there a way to prevent it ?

Here is capture of my ram usage.

ipeph@ServiceOperationCenter:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          9748       6018       3720         10        141       5679
-/+ buffers/cache:        392       9354
Swap:          893          0        893

ipeph@ServiceOperationCenter:~$ date
Thu Nov 19 09:44:37 WIB 2015

ipeph@ServiceOperationCenter:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          9748       6113       3619         10        141       5679
-/+ buffers/cache:        395       9350
Swap:          893          0        893

ipeph@ServiceOperationCenter:~$ date
Thu Nov 19 09:44:57 WIB 2015

ipeph@ServiceOperationCenter:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          9748       6213       3534         10        141       5679
-/+ buffers/cache:        402       9355
Swap:          893          0        893

ipeph@ServiceOperationCenter:~$ date
Thu Nov 19 09:45:03 WIB 2015
6
  • 1
    I disable FTP on my servers. I strictly use SFTP. From the users perspective it is almost the same.
    – Goddard
    Nov 19, 2015 at 3:03
  • I can't see a problem. You use 200MB more?
    – A.B.
    Nov 19, 2015 at 5:44
  • " is there a way to prevent it ?" why would you want that? If anything it will make your system slower not faster.
    – Rinzwind
    Nov 19, 2015 at 13:32
  • @A.B i'm use 10GB RAM Nov 20, 2015 at 9:50
  • 1
    In short; your ram usage isn't increasing. You are just looking at the wrong line of free. Look at the -/+ cache line, which shows your memory usage went from 395m to 402m, hardly an increase at all.
    – psusi
    Nov 26, 2015 at 1:19

2 Answers 2

2

The Linux kernel will keep file data cached in memory in case it is accessed again. Over time, the data will be discarded if it is not accessed or other processes require the memory. The cached stats show how much data is in the cache. I would not get overly concerned about this.

If you do want to drop cached data (which is not advisable since you may be freeing up cached data and hence the kernel will have to re-read it again), you can write 1 to /proc/sys/vm/drop_caches to free up the pagecache.

To free pagecache:

echo 1 | sudo tee /proc/sys/vm/drop_caches

To free reclaimable slab objects (includes dentries and inodes):

echo 2 | sudo tee /proc/sys/vm/drop_caches

To free slab objects and pagecache:

echo 3 | sudo tee /proc/sys/vm/drop_caches
0

In free output, the most important figure is + buffers/cache which is free + buffers + cached, it indicates memory available to your applications when needed.

- buffers/cache == used - buffers - cached which is a good indication of memory occupied by applications

Linux (kernel) makes use of unused memory for page cache (and buffer cache - it still exists) to for performance.

free -> not used for anything

echo 3 > /proc/sys/vm/drop_caches frees pagecache, dentries and inodes which will return memory used for page cache / buffer cache to "free".

buffers and cached will drop and free will increase, however, that doesn't mean you have more memory available for applications.

For more information, check Linux at my RAM!

BTW: Fedora and Arch Linux use free from procps-ng output is different.

The output combines buff/cache and removed the somewhat confusing -/+ buffers/cache.

We can clearly see buff/cache dropped but available did NOT change, which makes a lot more sense to end users. I personally think it is a better implementation/interpretation.

# free -m
              total        used        free      shared  buff/cache   available
Mem:           1874         117          18           1        1737        1708
Swap:             0           0           0
# echo 3 > /proc/sys/vm/drop_caches
# free -m
              total        used        free      shared  buff/cache   available
Mem:           1874         117        1654           1         102        1708
Swap:             0   

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .