Jun 18, 2007

Physical and Virtual Memory

Storage Access Patterns

  • Access tends to be sequential

If address N is accessed by the CPU, it it highly likely that address N+1 will be accessed next.

  • Access tends to be localized

If address X is accessed, it is likely that other addresses surrounding X will also be accessed in the future.

The Storage Spectrum

Storage technologies:

  • CPU registers

  • Cache memory

  • Ram

  • Hard drives

  • Off-line backup storage (tape, optical disk, etc.)

Virtual Memory

Virtual memory is a portion of the hard disk that operation system uses to application programs to meet the require exceeds the amount of physical memory available.

Paging occurs when an active process requires more memory than what is accessible in physical memory. Portions of the process are moved to disk so the physical memory can be used for something else.

Swapping is done by the kernel. When memory space is running low the kernel looks for a process that isn't likely to run in the near future. That process is written entirely to disk, and the newly-freed memory is reassigned to another process or job.

Virtual Memory in Redhat Linux

    Using free to get a concise overview of memory and swap utilization.

$ free

total used free shared buffers cached

Mem: 1023368 1004148 19220 0 14544 277328

-/+ buffers/cache: 712276 311092

Swap: 2031608 198436 1833172

System has 1G of RAM, about ~1004 MB is actually in use. ~198 MB of swap is in use.

sar [-a] [-A] [-b] [-c] [-d] [-g] [-k] [-m] [-p] [-q] [-r] [-u] [-v] [-w] [-y ] [ -o filename ] t [ n ]

Viewing result of sar -r

091712LINUX RESTART
09
2002 kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad
09
300235432 987936 96.54 30024 523368 2031444 164 0.01 0
09
400133080 990288 96.77 37776 512900 2031444 164 0.01 0
09
500113600 1009768 98.67 45868 516460 2031444 164 0.01 0
10
000157096 966272 94.42 52216 469420 2031444 164 0.01 0
平均値
: 34802 988566 96.60 41471 505537 2031444 164 0.01 0
kb: Kilobytes of memory allocated to
sar -W

091712LINUX RESTART
09
2002pswpin/s pswpout/s
09
30020.00 0.07
09
40010.00 0.00
09
50010.00 0.00
10
00010.00 0.00
平均値
: 0.00 0.02

page swap in per second (pswpin/s)
page swap out per second (pswpout/s)

No comments: