0

I have two OS on my pc. I installed Ubuntu 18.04 alongside with Windows 10. Total ram is 3.94 gb.

On Ubuntu my total ram is bigger than sum of free ram and used ram by 1,5 gb. And buff/cache is 1.5gb.

Is it normal, and it is just how linux works and if i will need more memory it will take from buff/cache? if not how to solve this problem?

$ watch -n 5 free -m
Every 5,0s: free -m                                                                                                     gleb: Sat Jul 21 14:34:49 2018

              total        used        free      shared  buff/cache   available
Mem:           3851        2048         214         343        1588        1184
Swap:          2047           0        2047


$ vmstat -s | head -10
gleb@gleb:~$ vmstat -s | head -10
  3943920 K total memory
  2102300 K used memory
  2350048 K active memory
   984768 K inactive memory
   209772 K free memory
    38824 K buffer memory
  1593024 K swap cache
  2097148 K total swap
        0 K used swap
  2097148 K free swap


$ cat /proc/meminfo | head -10
MemTotal:        3943920 kB
MemFree:          181792 kB
MemAvailable:    1126248 kB
Buffers:           32236 kB
Cached:          1463972 kB
SwapCached:            0 kB
Active:          2340464 kB
Inactive:        1021944 kB
Active(anon):    1691844 kB
Inactive(anon):   588964 kB

$ sudo lshw
description: Notebook
product: 80SM (LENOVO_MT_80SM_BU_idea_FM_Lenovo ideapad 310-15ISK)
vendor: LENOVO
version: Lenovo ideapad 310-15ISK
serial: PF0L15FM
width: 64 bits
...
-memory
      description: System Memory
      physical id: 26
      slot: System board or motherboard
      size: 4GiB
     -bank:0
         description: SODIMM DDR4 Synchronous 2133 MHz (0,5 ns)
         product: M471A5244BB0-CPB
         vendor: Samsung
         physical id: 0
         serial: 00000000
         slot: ChannelA-DIMM0
         size: 4GiB
         width: 64 bits
         clock: 2133MHz (0.5ns)
abu_bua
  • 10,783
Geba
  • 1

1 Answers1

0

The way Linux handles the RAM depends on the Linux kernel version but in big picture, it goes roughly like this:

The actual hardware has X amount of RAM. The Linux boots and takes control of the RAM as much as possible (some may be reserved by BIOS/firmware, some other part by integrated graphics, etc). The rest of the RAM is first free.

During the kernel boot the Linux kernel locates the filesystem and starts init process (nowadays SysV init, Upstart or Systemd) that needs some RAM and will start additional processes from that point forward. All content that has been fethed from the filesystem will be kept in cache if possible. This allows kernel to skip reading the filesystem (and hard drive) in the future if the same data is needed again. The RAM that init or any other user mode process needs for processing instructions in CPU is called used.

By default, every time a user mode process writes something to the filesystem, the kernel will instead put the written contents to buffers and pretend to the user mode process that the data was already written to the filesystem. The user mode process continues and the kernel proceeds to write the buffers to the filesystem (and hard drive) in paraller.

In the end, used RAM is the part of the RAM that cannot be easily freed if another process needs more RAM. free RAM is part of the RAM that is not used for anything (practically wasted RAM) and buffer or cache are part of RAM that is used to speed up I/O. If some process needs more RAM than is free, the buffer and cache RAM is sacrificed but overall performance may suffer as a result.

As for the problem you mentioned in the comments about system working slower when some specific application is run, you would need to share more information about that specific case. Most probably the application you run on Linux and the "same" application on Windows are not the same thing.