Virtual Memory vs. Physical Memory

This section describes virtual memory, which is mapped to physical memory through MMU (Memory Management Unit).

What Is VM (Virtual Memory)? - Virtual Memory (VM) is a memory management technique that provides an abstraction of the storage mapped to PM (Physical Memory), which is combination of RAM and Swap space on hard disk.

What Is MMU (Memory Management Unit)? - Memory Management Unit (MMU) is a hardware unit that manages the mapping between the virtual memory and the physical memory. MMU actually translates a virtual memory address to a physical memory address using page tables.

What Is PM (Physical Memory)? - Physical Memory (PM) is a combination of the RAM (Random Access Memory) and a Swap space configured on the hard disk. This combination allows the computer system to run programs that require memory larger than the RAM.

The diagram below shows how MMU maps VM to PM.

Virtual Memory (VM) vs. Physical Memory (PM)
Virtual Memory (VM) vs. Physical Memory (PM)

"free" - Display Memory Usage - "free" command displays usage of the physical memory which is combination of RAM and Swap space on hard disk. The following output shows 693,616 KiB used out of the 4,761,456 KiB physical memory.

herong$ free -t

          total    used     free  shared  buff/cache  available
Mem:    3711860  411064  2296828    1780     1003968    3059216
Swap:   1049596  282552   767044
Total:  4761456  693616  3063872

Note that:

"top" - Display Memory Usage - "top" command displays resource, including memory, usages of total and individual running processes. The RAM (Mem) and Swap usage numbers matches well with the "free" command output.

herong$ top 

top - 21:29:34 up 160 days,  6:33,  1 user,  load average: 0.00, 0.06, 0.07
Tasks: 142 total,   1 running, 141 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.8 us,  0.5 sy,  0.0 ni, 97.5 id,  0.0 wa,  0.2 hi,  0.0 si,  0.0 st

MiB Mem :   3624.9 total,   2239.3 free,    402.3 used,    983.2 buff/cache
MiB Swap:   1025.0 total,    749.1 free,    275.9 used.   2986.5 avail Mem 
...

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

Memory Management

 Layers of Memory and Access Speed

 List CPU Caches and Their Sizes

Virtual Memory vs. Physical Memory

 Buffer Memory and Cache Memory

 Verify Cache Memory with "cp" Command

 What Is Swap Space

 Virtual Memory Mapping and Page Table

 "ps -o rss,drs,trs,vsz,sz" - Process Status Options

 smem - Process Memory Usage Report

 pmap - Process Memory Map

 /proc/{id}/maps - Process Memory Map

 /proc/{id}/smaps - Process Memory Map Details

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks

 References

 Full Version in PDF/EPUB