Home » Linux Basics » 01 - An Introduction to Linux
1

Memory Management Basics

Learning the memory management basics

Users normally use only a small portion of the entire memory requirement of a software program at any time. For example, a user may edit (enter data into or modify) a document opened through spreadsheet software for some time; she may then perform import-export operations, and later summations. An open e-mail program may remain idle while the user works on the spreadsheet. Linux does not load an entire program into RAM. Initially, it only loads components required to get the program started. Parts that are not required are kept on a special partition of the hard disk and swapped in when required. Idle programs are also swapped out onto the hard disk until the user starts using them. A specific portion of the hard drive is designated as the swap partition during system installation. This partition is sometimes equivalent to the RAM capacity of the system; it is sometimes twice the RAM capacity. Due to the swap space on the hard disk and selective loading of programs, the number of programs Linux can load at one time is not capped by the actual RAM memory capacity of the system; the system's virtual memory capacity is much higher than it"s actual RAM memory

Saving a new or modified file is not instantaneous but a process made up of many steps. Linux internally writes data to be written to the disk onto a 'buffer'. Such requests are gathered and the data stored (or cached) into the buffer until the buffer is full. Only then does an actual saving to disk takes place. This saves time; frequent writes to the hard drive are very expensive. Also, any requests for frequently accessed data may be fulfilled from the buffer cache rather than a disk lookup. Since the buffer cache is in RAM, data on it may be accessed a lot faster than data on the disk.