10

Just switched 4GBs to 16GBs of RAM. However, when I look at how much memory I have, it says 15.3. I'm just wondering why did my memory drop down when I just installed 16 GBs of RAM.

system details screenshot

Melebius
  • 11,431
  • 9
  • 52
  • 78
Geri Sati
  • 123

1 Answers1

24

Short Answer

It's probably just the kernel using memory. Instead of reporting kernel memory usage, Ubuntu instead subtracts form the total available. This is simply to let you know that the kernel memory cannot be freed in most cases. That memory is being used for things that are absolutely necessary, and so it will never be available.

Diagnostic Commands

I don't expect you to run all of these, but I've included them here for reference and completeness. Most relevant are commands 3 and 4. Also please note that all sizes are going to be in base 2 (e.g. GiB) and not in base 10 (e.g. GB) despite what the unit abbreviations might be.

  1. You can check how big your RAM sticks are claiming to be with:

    sudo dmidecode | grep Size | grep MB
    
  2. You can check how much RAM is available for general use with (look for Mem and total):

    free -h
    
  3. You can estimate how much memory the kernel is using with:

    cat /proc/meminfo | grep Slab
    
  4. You can check for "stolen" graphics card memory with:

    dmesg | grep stolen
    
  5. You can look for specific hardware reserved memory by looking through:

    dmesg | grep e820
    
  6. You can test to make certain all of your memory works by running memtest

Explanation

The most likely explanation is simply that the extra space is being used by either your graphics card or the kernel itself. If you're not familiar, the kernel is the lowest-level part of the operating system, and any memory that it's using will not be available to you and so is not reported as free. The memory might be used for any number of reasons, such as the virtual memory tables, memory-mapped I/O, kernel processes, certain caches, shared graphics memory, etc.

Example: Looking at My Laptop

It is very likely that adding the output of command 3 to your 15.3GiB will result in almost exactly 16GiB. This was the case in my system:

  • Installed RAM: 6GiB
  • Reported in System Settings > Details: 5.6GiB
  • Output of cat /proc/meminfo | grep Slab: 316652 kB
  • Converted to GiB: 316652/2^20 = 0.3GiB
  • Output of dmesg | grep stolen: 32768K
  • Converted to GiB: 32768/2^20 = 0.03GiB
  • Adding them together: 5.6 + 0.3 + 0.03 = 5.93GiB

Since the Slab memory is not comprehensive, we can assume that the kernel is using the remaining 0.07GiB in places we can't see, and so this is a very satisfying result.

See Also

TheSchwa
  • 3,820
  • 2
    Kernel slab memory is counted as part of "used memory" and does not reduce the "total" memory. You can see that quite easily by checking the system when it has a lot of slab in use, and again when it is little. – psusi Jun 08 '17 at 13:40
  • 1
    cat | grep is a useless use of cat: grep itself accepts filenames as parameters. – Ruslan Jun 08 '17 at 16:44
  • @Ruslan Lol, thanks. I still haven't trained myself out of that one. Albeit it's less "correct" in some sense, I still like it for readability and it flows better with the other commands in the post. – TheSchwa Jun 08 '17 at 19:00
  • I disagree that it is useless. With command-line ctrl keys, it can be faster to issue a series of grep commands with the cat xxx | grep yyy approach. And often the only thing changing is the grep pattern from file to file and it ends up being faster overall – Troy Folger Mar 25 '23 at 06:02