Memory is something that stores, preserves and recalls data when needed. Computers have this capability and their memory is an electronic incarnation of this concept. Computer memory stores data that is accessed by the Central Processing Unit (CPU). It is the CPU that performs the laborious tasks. Thus, memory acts as storage for uncompleted tasks and other information needed to accomplish those tasks.
Forms of Memory
Although the term "Computer Memory" is commonly used to refer to RAM, there are various other forms of memory inside a computer – such as the hard disk drive. Purchasing a computer with adequate memory is extremely important whether you own a small business or you're an avid gamer who needs the best performance possible.
The illustration below outlines the common memory architecture within most modern computers.
Any of the four major categories of memory in the diagram above can feed information directly to the CPU. Each form of memory feeds the CPU at differing speeds and efficiency due to their different technological make up.
Registers and Cache will transfer data to the CPU at greater speeds than RAM and hard disk drives. As the forms of memory in the top of the pyramid are costly to make, their size are limited to make computers affordable. The size of memory forms towards the bottom of the pyramid is made larger to hold all the other data that other forms cannot handle.
It should also be noted here that Physical RAM and cache are volatile in nature – meaning they store, preserve and recall data so long as there is electrical power flowing through the system. Once a computer system is shut off, the physical RAM and cache are cleared. Disc Storage by way of floppy disk, hard disk, CD-ROM and DVD-ROM drives hold information that are required to be non-volatile in nature such as that project you have been working on.
There is a trade-off between speed and cost, resulting in the development of such a pyramid-like architecture. Information is prioritized in terms of importance and stability to determine which form of memory would hold the data.
The bottle-neck in a memory and CPU architecture is the slow transfer speeds between the two. The fastest, and sadly the most expensive, form of memory resolves this problem by having the memory within the CPU itself. Data within registers are instantly fed to the Arithmetic and Logic Unit (ALU) portion of the CPU making the relevant data instantly available.
Registers are typically small in size and is controlled by the CPU's compiler.
This form of memory can be considered as an intermediary between the main physical RAM and the CPU. The cache makes any data frequently used by CPU instantly available. If the required information is not located in the cache, a fetch is made from the main memory.
There are two levels of cache: Level 1 Cache (primary cache) and Level 2 Cache (secondary cache).
Level 1 cache is built directly on the CPU, just like the registers. It is small in size, ranging anywhere between 2 kilobytes (KB) and 128KB. As this cache is closer to the CPU than level 2 cache, its transfer speeds are much faster as a result.
Level 2 cache is usually situated in close proximity to, but off, the CPU chip. However, there are certain systems where the cache is built directly onto the CPU itself as like the level 1 cache. The size of level 2 cache ranges from 256KB to 2 megabytes (MB). Both levels of cache use Static Random Access Memory (SRAM) to hold the data.
This is where most of the information that a CPU requires resides. "Main Memory" commonly refers to Physical Memory, although a computer uses an operating system-imposed Virtual Memory in addition to physical memory.
Physical memory uses Dynamic Random Access Memory (DRAM) to store the data, and is considerably slower than the SRAM used by the cache. (More information on DRAM and SRAM). Information is exchanged between the main memory and the cache to ensure that the more commonly accessed information is placed in the cache to allow faster access speed.
The physical memory acts as an Input/Output (I/O) channel for data exchanged between the computer memory and other forms of electronic storage.
Most operating systems have a form of memory management that caters for memory needs beyond a computer system's physical memory through the use of a Swap File. There is a need for such memory management as operating systems themselves occupy a significant portion of physical memory.
A Swap File is a file located on a computer's hard disk drive (HDD) that acts as an extension to physical memory. However, the HDD has much slower access times than any of the forms of memory discussed above. Hence, information is swapped between the main memory and the swap file to ensure that the more frequently used information is located in the main memory for faster access speeds.