Memory
Computer memory simplified
What Is Memory?
There are a few types of memory in computers, some are analog, some are digital
Some are responsible for short term memory, some for long term memory
What's the difference between Volatile and Non-Volatile memory?
Volatile memory is a type of memory that only holds information while the device is on -> Once it loses electricity, all the stored data is flushed with it
Non-Volatile memory is a type of memory that holds information no matter if the device is on or not
Types Of Memory
Short Term Memory (Volatile)
Physical Memory
Physical memory (AKA RAM - Random Access Memory) is a short term memory that is responsible to store information only when the computer / electronic device is ON
Once the device turns off, all memory is flushed (this type of memory does not hold a charge in it's memory cells)
Registers
A register is a small cell of memory that is used by the CPU
A register can hold as much info as the architecture of the CPU (32bit / 64bit / etc)
Meaning that a 64bit CPU has 64bit registers (can store up to 64bit of data on each register)
CPU Cache
You know how on every CPU specs you have a certain number of L3, L2, L1 cache memory? those are memory cells as well - it's also the fastest memory in the whole computer and also the closest memory to the CPU itself as it is inside it (On most modern CPUs)
- Cache performance: L1 > L2 > L3
- Cache size: L1 < L2 < L3
You might be asking, if L1 is the fastest but also the smallest, why not just make it all L1? well, I'll put a source for you to read about it here
TL;DR: From a physical point of view -> The bigger the cache, the harder to search for what you need
Long Term Memory (Non-Voilatile)
Storage Devices
There are 4 main ways to store data in our modern world:
- Hard Disk Drives (HDD) -> Store data by using a rotating disk where the needle reads and writes data by changing a specific part of the disk magenticity
- Solid State Drive (SSD) -> Store data by "trapping" electrons in data storage cells (basically if it's populated with an electron it's 1 and if not it's 0)
- Phsical Disks (CD / DVD / BluRay / etc) -> Store data by etching it into the disk with lasers
- Tape Drives -> Like HDDs, a tape uses magenticity but the main difference between the two is that HDDs can store data in random spots on the disk while a tape is linear and stores data in sequence
Did You Know?
Have you ever got the chance to format a drive (erase it) so you could use it yourself or give it to someone else?
Well, did you notice that in Windows for example it always pre-checks the option for quick format?
Have you ever asked yourself why?
Well to understand this we'll need to quickly go over (in a high level) on how file systems work: When you save a file and see it on your computer, what actually happens is as follows:
- The data is written to the storage device
- The FS creates metadata regarding the file in its lookup table
The metadata contains info like creation date, last modified, permissions to the file, where is it stored on the computer (Desktop / Downloads / other folders or directories) and also where the data starts and where it ends
- You see the file or folder where you downloaded / pasted / moved / copied it to
Well, when you pick quick format, what it does is it goes over all the metadata and deletes it from the lookup table (or changing the structure of the lookup table all together if you're changing the format itself as well)
But it does not delete the actual content, it's still there somewhere, you just lost your convenience of finding it fast (That's why businesses that offer data recovery actually work)
On the other hand, if you're not using quick format, what it does is it goes over every sector (data point) in the storage device and sets it to 0
Meaning that even if you'll go to a data recovery service, you probably won't be able to restore your files
Here's a little bonus for reading this far:
What's the fastest memory in the system?
Well it begins with the CPU registers and L1 cache
From there it's getting slower and slower the higher you go: L1 > L2 > L3 > RAM > Storage Devices
So if you were asking yourself why is it so complex, it's mainly because of performance. The biggest bottleneck on our system is the speed of our system's slowest storage device -> Keep this in mind when considering upgrading your computer!