What is Memory?
The fundamental purpose of memory, whether human or machine, is to store information over time. A striking aspect of human memory is its remarkable ability to forget. While this may initially seem like a flaw, it serves as an advantageous strategy for focusing on what truly matters amidst the constant influx of stimuli in our lives. Forgetting acts as a means of prioritizing important information and discarding irrelevant details, akin to clearing out old items from a closet to make space for new ones.
Unlike human memory, computers do not operate in the same manner of remembering and forgetting. Instead, they function in binary—either knowing something or not. Once computers acquire knowledge, they typically retain it indefinitely, barring any catastrophic failures. Humans, on the other hand, possess the ability to recognize familiar things or recall learned information without necessarily being able to retrieve them at will. This cyclical process of forgetting and remembering gives human memory a nuanced and almost magical quality, distinct from the more deterministic nature of computer memory.
While celebrated individuals may master techniques enabling them to memorize vast amounts of information, their feats are often likened to acts of magic or artistry. Yet, in comparison to the straightforward storage capabilities of a modest USB flash drive, the achievements of these individuals pale in comparison—underscoring the contrast between human memory's complexity and the straightforward functionality of computer memory.
The two types of memory
Human brains and computers share the characteristic of having different types of memory. Human memory is divided into short-term "working" memory, which holds recently processed information, and long-term memory, which stores facts, experiences, and learned skills for extended periods. Similarly, computers typically feature two distinct kinds of memory.
Firstly, there's the built-in main memory, also known as internal memory, comprised of silicon chips or integrated circuits. This memory facilitates rapid data storage and retrieval, assisting the computer in processing tasks at hand. Main memory is volatile, meaning it loses its contents when the power is turned off. To address this limitation, computers are equipped with auxiliary memory or storage, which retains information even when power is disconnected. In desktops or laptops, auxiliary memory is commonly provided by hard drives or flash memory. It's also referred to as external memory, harking back to older, larger computers where it resided in a separate machine linked to the main computer box via a cable. In modern PCs, auxiliary storage can take various forms such as USB flash drives, SD memory cards (used in devices like digital cameras), plug-in hard drives, CD/DVD ROMs, and rewriters.
In practical terms, the distinction between main memory and auxiliary memory can become somewhat blurred. Computers typically have a limited amount of main memory, ranging from around 512MB to 4GB in modern systems. The more main memory a computer has, the faster it can process information and complete tasks. However, if a computer needs to store more data than its main memory can accommodate, it employs a technique called virtual memory.
Virtual memory allows the computer to temporarily transfer less critical data from main memory to its hard drive, freeing up space in main memory. This process enables the computer to continue functioning when it exceeds its physical memory limits. However, accessing data from a hard drive is significantly slower than from main memory due to mechanical limitations, leading to decreased performance. When virtual memory is activated, you may hear the hard drive operating rapidly as it reads and writes data between virtual and physical memory.
Ultimately, computers with more main memory operate more efficiently because they can handle larger amounts of data without relying heavily on slower virtual memory operations. Increasing main memory reduces the frequency of virtual memory usage, resulting in improved system performance.
- Internal Memory:
- Internal memory refers to all types of memory directly accessible by the CPU within the computer system.
- It includes both volatile and non-volatile memory memory components.
- Examples of it include RAM (Random Access Memory), ROM (Read-Only Memory), cache memory, and registers.
- Main Memory (Primary Memory):
- It is subset of internal memory that serves as the main storage location for data and instructions that the CPU actively uses.
- It includes volatile memory components such as RAM, which are directly accessible by the CPU and used for temporary storage of data during program execution.
- It is typically faster and more expensive than secondary memory but has limited storage capacity.
- Secondary Memory (Auxiliary Memory):
- It refers to storage devices that are external to the CPU and main memory, used for long-term storage of data and programs.
- It includes non-volatile memory components such as hard disk drives (HDDs), solid-state drives (SSDs), optical drives (CD-ROMs, DVD-ROMs), and magnetic tapes.
- Secondary memory provides larger storage capacity compared to main memory but has slower access times.
Internal Memory types
The internal memory of a computer is commonly categorized into two main types: Random Access Memory (RAM) and Read-Only Memory (ROM).
- Random Access Memory (RAM):
- RAM is a type of memory that allows data to be read or written to any order, enabling quick access to stored information.
- It serves as temporary storage for data and instructions that the CPU actively uses during program execution.
- RAM is volatile, meaning its content are lost when the computer is powered off. This characteristic makes it ideal for storing data that needs to be accessed quickly but doesn't need to be retained permanently.
- RAM is further subdivided into different types such as Dynamic RAM (DRAM) and Static RAM (SRAM), each with its own characteristics regarding speed, power consumption, and cost.
- Read-Only Memory (ROM):
- ROM is a type of memory that contains pre-programmed data or instructions that cannot be easily modified or overwritten.
- It is used to store firmware and essential system software that the computer needs to boot up and perform basic functions before loading the operating system.
- ROM is non-volatile, meaning its contents are retained even when the computer is powered off. This makes it suitable for storing critical system-level data that should not be altered.
- There are different types of ROM, including Mask ROM (factory-programmed), Programmable ROM (PROM), Erasable Programmable ROM (EPROM), and Electrically Erasable Programmable ROM (EEPROM), each with varying levels of flexibility and reprogrammability.
DRAM and SRAM
RAM comes in two main varieties called DRAM (Dynamic RAM) and SRAM (Static RAM).
- Dynamic Random Access Memory (DRAM):
- DRAM is a type of volatile memory that stores each bit of data as an electric charge in a capacitor within an integrated circuit.
- It requires constant refreshing of its memory cells to maintain the stored data, as the electric charge stored in capacitors tends to leak over time.
- DRAM is typically used for main memory in computers due to its high storage density and lower cost compared to SRAM.
- It offers slower access times compared to SRAM due to the need for periodic refresh cycles.
- DRAM modules are commonly used in systems as DIMMs (Dual Inline Memory Modules) or SO-DIMMs (Small Outline DIMMs).
- Static Random Access Memory (SRAM):
- SRAM is a type of volatile memory that stores data using flip-flop circuits, which retain their state as long as power is supplied to the circuit.
- Unlike DRAM, SRAM does not require periodic refreshing of its memory cells, making it faster and more power-efficient.
- SRAM offers faster access times compared to DRAM, making it suitable for use in cache memory and other applications where high-speed access is crucial.
- However, SRAM is more expensive and has lower storage density compared to DRAM.
- SRAM is commonly used in cache memory, register files, and other applications where high-speed access is critical.
Differences between different types of memory
Memory Type | Volatility | Accessibility | Speed | Persistence | Capacity | Examples |
---|---|---|---|---|---|---|
RAM (Random Access Memory) | Volatile | Directly accessible by CPU | Fast | Data is lost when powered off | Limited by hardware constraints | DDR4, DDR3, SRAM, DRAM |
ROM (Read-Only Memory) | Non-volatile | Directly accessible by CPU | Fast | Data is permanent | Fixed (depends on ROM size) | BIOS ROM, Firmware ROM, Mask ROM |
Cache Memory | Volatile | Directly accessible by CPU | Very Fast | Data is temporary | Limited (smaller than RAM) | L1 Cache, L2 Cache, L3 Cache |
Registers | Volatile | Directly accessible by CPU | Ultra Fast | Data is temporary | Extremely limited (few KBs) | General Purpose Registers, Instruction Registers, etc. |
Virtual Memory | Both volatile & non-volatile | Indirectly accessible by CPU (managed by OS) | Slower than RAM | Data may be swapped to disk | Virtually unlimited | Paging file (swap), Page tables, Virtual memory mappings |
Hard Disk Drive (HDD) | Non-volatile | Indirectly accessible by CPU | Slow (compared to RAM) | Data is permanent | Large (typically several TBs) | Traditional mechanical hard drives |
Solid State Drive (SSD) | Non-volatile | Indirectly accessible by CPU | Faster than HDD | Data is permanent | Large (typically several TBs) | Flash-based storage devices |
Optical Discs (CD-ROM, DVD-ROM, etc.) | Non-volatile | Indirectly accessible by CPU | Slower than HDD | Data is permanent | Limited (depends on disc capacity) | CD-ROMs, DVD-ROMs, Blu-ray Discs |
Magnetic Tapes | Non-volatile | Indirectly accessible by CPU | Slowest | Data is permanent | Extremely large (several PBs) | Magnetic tape storage systems |
+-----------------------------------+
| Computer |
+-----------------------------------+
/ | \
/ | \
/ | \
+----------------+ +----------------+ +----------------+
| Internal | | Main Memory | | Secondary |
| Memory | | (Primary | | Memory |
| | | Storage) | | |
+----------------+ +----------------+ +----------------+
/ \ | / \
/ \ | / \
/ \ | / \
+-------------+ +------------+ +------------+ +--------------+
| Cache | | Registers | | RAM | | Secondary |
| Memory | | | | | | Memory |
| (High-speed)| | (Ultra- | | (Volatile) | | Devices |
| Temp) | | fast) | | | | (Non- |
+-------------+ +------------+ +------------+ | Volatile) |
+--------------+
Hierarchy of Memory
+--------------------------------------------------------+
| Memory Hierarchy |
+--------------------------------------------------------+
| Internal Memory |
| +----------------------------------------------------+ |
| | Cache Memory | |
| | (L1, L2, L3 Cache) | |
| +----------------------------------------------------+ |
| | Registers | |
| | (Inside CPU Core) | |
| +----------------------------------------------------+ |
| |
| Main Memory (RAM) |
| +----------------------------------------------------+ |
| | Main System Memory | |
| | (Volatile, Fast) | |
| +----------------------------------------------------+ |
| |
| Secondary Memory |
| +----------------------------------------------------+ |
| | SSDs, HDDs, | |
| | Optical Discs, Tapes | |
| +----------------------------------------------------+ |
| |
+--------------------------------------------------------+
This Memory Hierarchy Design is divided into 2 types:
- Primary or Internal Memory: It consists of CPU registers, Cache Memory, Main memory, and these are directly accessible by the processor.
- Secondary or external Memory: It consists of a magnetic disk, optical disk, magnetic tape, which are accessible by processor via I/O module.