In computing, memory refers to the physical devices used to store programs (sequences of instructions) or data (e.g. program state information) on a temporary or permanent basis for use in a computer or other digital electronic device.
Primary memory
Primary memory
Primary memory is computer memory that is accessed directly by the CPU. This includes several types of memory, such as the processor cache and system ROM. However, in most cases, primary memory refers to system RAM.
RAM, or random access memory, consists of one or more memory modules that temporarily store data while a computer is running. RAM is volatile memory, meaning it is erased when the power is turned off. Therefore, each time you start up your computer, theoperating system must be loaded from secondary memory (such as a hard drive) into the primary memory, or RAM. Similarly, whenever you launch an application on your computer, it is loaded into RAM.
The operating system and applications are loaded into primary memory, since RAM can be accessed much faster than storage devices. In fact, the data can be transferred between CPU and RAM more than a hundred times faster than between the CPU and the hard drive. By loading data into RAM, programs can run significantly faster and are much more responsive than if than constantly accessed data from secondary memory.
Secondary memory
Secondary memory refers to storage devices, such as hard drives and solid state drives. It may also refer to removable storage media, such as USB flash drives,CDs, and DVDs.
Unlike primary memory, secondary memory is not accessed directly by the CPU. Instead, data accessed from secondary memory is first loaded into RAM and is then sent to the processor. The RAM plays an important intermediate role, since it provides much faster data access speeds than secondary memory. By loading software programs and files into primary memory, computers can process data much more quickly.
While secondary memory is much slower than primary memory, it typically offers far greater storage capacity. For example, a computer may have a one terabyte hard drive, but only 16gigabytes of RAM. That means the computer has roughly 64 times more secondary memory than primary memory. Additionally, secondary memory is non-volatile, meaning it retains its data with or without electrical power. RAM, on the other hand, is erased when a computer is shut down or restarted. Therefore, secondary memory is used to store "permanent data," such as the operating system, applications, and user files.