System Memory

Memory Subsystem -- Virtual Memory
A Linux system has certain amount of physical memory and Linux breaks this up into "chunks" or "pages" of memory rather than bytes.  On the IA32 architecture, the page size is 4K and can cause too much overhead to track.  Therefore, the kernel maipulates memory into bigger chunks know as "HugePages".  These are 2048KB rather than 4KB and greatly reduce the overhead of managing very large amount of memory.  Oracle use the huge pages to load an enormous amount of data in memory to miniming the overhead that the Linux kernel has to mange it. 

Swap -- when not enough physical memory
Linux kernel alows applications to run even when there is not enough physical available memory.  The Kernel uses the hard drives as temporary memory called swap space.  Swap is terribly slow and can be up to 1,000 times slower than physical memory. 

Buffers v.s Cache
If your system has more physical memory than required by applications, Linux will cache the recently used files in physical memory to speed up the subsequent access to that file.  When an application is launched, it first reads from disks then if the applications remains in the cache, it will be read much quicker.  Linux also uses extra set-aside memory as buffers.  If an application writes something to disk, it whould take a long time, so Linux lets the application continuously drives but save the file data into a memory buffer.  At sometime later, the buffer is flushed to disk while the application can continue immediately.

Active v.s Inactive Memory
Active memory is being used by a process while Inactive memory is allocated by has not been used for awhile.  Linux kernel takes the least recently used memory pages and move them to the inactive list.  The kernel chooses inactive memory to be swapped to disk when the system needs memory.

Kernel Memory
The Linux Kernel consumes certain amount of memory to manage the system like memory to track of data from network and disk I/O, which processes are sleeping or running.  The kernel has a series of cahces that contains one or more slabs of memory.

No comments:

Post a Comment