When discussing flash memory vs. RAM, you might be inclined to lump them together based on their similarities. While both technologies are made up of solid-state chips and fall into the category of solid-state storage, the way they are made, their performance specifications and the relative costs give them entirely different roles in a computer system.
Flash memory is used primarily for storage, while RAM (random access memory) contains code and performs calculations on the data retrieved from storage. By their nature, flash memory and RAM are faster than hard disk and tape.
In terms of flash memory vs. RAM speed, RAM is the faster of the two, but it is also more expensive.
Two types of RAM are commonly used in a computer system: dynamic RAM (DRAM) and static RAM (SRAM). In addition to being the fastest option, SRAM is much more expensive than DRAM, so it is mainly used as the cache memory inside the integrated circuit that is a computer's CPU. DRAM is mainly used as the primary operational memory, running the OS and applications.
Less expensive still is flash memory. Flash memory is non-volatile and can hold data even without power, unlike RAM. Compared to either type of RAM, flash memory speed is significantly slower. Because of its reduced power consumption, persistent nature and lower cost, flash is used for storage in devices such as SSDs, SD cards and USB drives.
This article is part of
How RAM works
At a basic level, RAM enables users to read from or write to any element of memory in whatever order they please. This sets it apart from tape and hard disk storage, which require admins to access data sequentially.
SRAM is built into a CPU, and users can't upgrade it. So, let's take a closer look at how DRAM works to better understand RAM. DRAM uses storage cells made up of a capacitor and a transistor. DRAM storage is dynamic -- it needs a new electronic charge every few milliseconds to compensate for charge leaks from the capacitor. Those storage cells are built into a solid-state chip, and those chips are collected into the familiar rectangular RAM DIMM module that is placed into the connectors on a computer's motherboard.
The computer OS running in RAM calls for data from storage -- SSD or HDD -- when needed, and the bits that make up that data are held in the RAM's cells until the OS or application writes them back to storage.
How flash memory works
NAND flash was developed to help reduce flash memory costs per bit and increase chip capacity. NAND flash's low cost enables it to complement more expensive DRAM in the system.
Data has to be erased from NAND flash memory in large blocks before any new data is written into the flash -- even if you only need to erase a few bits of data in the block -- as opposed to individual bytes, as is the case with RAM. These erase cycles are slow, as are flash writes, taking milliseconds to perform. Flash writes and erases create large stresses within the chip and cause it to wear out, which is not something that happens to RAM.
Clever programming algorithms make flash memory last much longer thanks to functions like wear leveling, write coalescing and bad block management. Wear leveling can prolong the life of flash memory by more evenly distributing rewrites and erasures. This avoids single blocks from a high concentration of write cycles, which can cause early failure.
A brief look at other memory types
One less common memory is Intel's Optane persistent memory modules. These are made of a new memory technology that fits between DRAM and NAND flash. It's nearly as fast as DRAM and can be written to in bytes without an erase cycle, yet it is non-volatile. Intel said last year that it is winding down its Optane persistent memory products.
Another is the non-volatile DIMM (NVDIMM), which is a DIMM that doesn't lose its contents in a power failure. It takes the DRAM in a standard DIMM and adds a battery and some NAND flash. In the event of a power loss, the NVDIMM detaches itself from the server's memory channel and uses the battery's power to move all of the DRAM's data into the NAND flash.
When power is restored, the NVDIMM moves all the data from the flash back into the DRAM, enabling the system to resume operation exactly where it stopped. This technology would be more popular if it didn't cost about five times more than a standard DRAM DIMM.