An Explanation Of How Computer Memory Works

Bytes - MegaBytes - Allocation And Temporary Storage

Memory is one of the core hardware components for the computer. It is the component that temporarily stores information (such as Numbers, Characters, Settings, Instructions, Files and so on) once a computer has started. The information is temporary because when a computer is switched off or restarted the information is deleted from memory. When a program has finished with the information, the memory it was using is released (not deleted) so other programs can then use that memory.

Fig 1.0  An old SDRAM Memory Stick for the computer - Size: 32MB (Megabytes) only. Speed: 100Mhz only.

Memory itself is a microchip (Fig 1.0) that can temporarily store Bytes. The more bytes the memory has the more information it can temporarily store. A byte is just a number with a value between 0 and 255. It's an application's job to turn each byte into something a human and/or another application can interpret. For example:

If the memory is storing 4 Bytes with the values 74, 79, 72 and 78 it would mean nothing to you. However. To Microsoft Word 2011 the byte value 74 means J. The byte value 79 means O. The byte value 72 means H and the byte value 78 means N. So even though the memory is storing byte values that mean nothing to you, Microsoft Word 2011 has no trouble interpreting (reading) those same byte values as JOHN.

The same applies to other applications that interpret (read) the byte values. For example: A Photo application might interpret 74 as colour Red, 79 as colour Yellow, 72 as colour Blue and 78 as colour Green. Whereas a Language program might interpret (read) 74 as English, 79 as Spanish, 72 as French and 78 as Italian. It depends on the application. Either way, the memory will always see 74, 79, 72 and 78. Here is a diagram of the memory with the 4 Bytes interpreted.

Fig 1.1  Byte values inside the Memory
Fig 1.2  Byte values as interpreted by Microsoft Word 2011

The logic behind interpreting byte values is like so: If the byte value is 74 display J (Microsoft Word 2011). If the byte value is 74 use English (Language program). If the byte value is 74 use colour Red (Photo application). And so on. In other words, the byte will always have its value of 74 but it can be interpreted differently depending on the application doing the interpreting.

Applications that save settings (preferences) files use interpretation a lot, to cut down on the number of bytes used. For example: If a photo application had to interpret RED, YELLOW and BLUE with characters it would use 13 Bytes (R E D Y E L L O W B L U E). Whereas using the logic of byte values to represent RED, YELLOW and GREEN it would only use 3 Bytes (79, 74 and 72).

Although the above concentrated on applications interpreting byte values that were already stored inside memory, the reverse is just as true. When you type the word JOHN into a Microsoft Word 2011 document for example its stores (puts) the byte values 74, 79, 72 and 78 inside memory. The same with a photo application. Instead of storing the characters R E D (byte values 82, 69 and 68) it might store the byte value 74 (which represents RED in the above example) so that it is uses 1 Byte, instead of 3, every time you use the red ink.

Basically, memory is just full of numbers that are interpreted by applications to mean Instructions, Settings (Preferences), Characters, Words, Sentences, Numbers, Symbols and so on.


When an application opens it first allocates some memory for its own needs. For example: If you open a 1000 bytes essay file with Microsoft Word 2011, from a floppy disk, and edit it (i.e. you change the word JOHN into PAUL) the changes are not made to the essay file on the floppy disk. They are made inside memory to avoid wear of the floppy disk. If you imagine every time you edited an essay character (byte value) the whole essay file had to be re-saved onto floppy disk you would soon end up with a damaged floppy disk. Just changing JOHN into PAUL would mean four re-saves. Memory is purposely made for the constant editing of byte values.

When Microsoft Word 2011 opens an essay file from floppy disk for example it first allocates (reserves) 1000 bytes of file memory, so it can store an exact copy of the essay file inside that memory - The original essay file on the floppy disk is left intact. The next thing Microsoft Word 2011 does is allocate some memory for its editing needs. So if you make a copy of the word JOHN, because you want to add (paste) it somewhere else in the essay, behind the scenes Microsoft Word 2011 makes a copy of the word JOHN by storing the word JOHN inside the edit memory. So you now have 1000 bytes full of essay characters inside the file memory and 4 bytes used inside the edit memory for the J O H N characters. However, because you might want to copy a paragraph, an whole essay page or even the whole essay Microsoft Word 2011 has to make sure it has allocated enough edit memory for these situations.

The same applies to the file memory - It might not be allocated just 1000 bytes for the essay characters, but perhaps 3000 bytes just in case you need to add more to the essay (i.e. you start copying bits out of an History/Research file into the essay or you just type more characters into the essay). So the essay might need 5000 bytes in total allocated for it. Once you have finished editing the essay, which is in file memory at this point, you then tell Microsoft Word 2011 to save the file memory back onto the floppy disk as an essay file.

A collection of bytes is known as Data. Microsoft Word 2011 sees a file, and memory, as a block of data only. This means when it opens a file all it's doing is copying a block of data (the file's bytes) from one place (i.e. a Floppy Disk) to another (i.e. into File Memory). The same applies when saving a file - It sees the bytes that make up the essay (i.e. "An essay about....") as a block of data that it can save from file memory onto a floppy disk. And that is how you should see files and memory - as blocks of data. Once the essay (file memory) has been saved onto the floppy disk, as an essay file, the file memory and edit memory are then released for other applications to use.

The above is okay when everything is running smoothly, but problems arise when an application tries to allocate memory that is not available. For example: If you try to open too many applications or files at once they might crash (Freeze/Stop) OS X (El Capitan or Sierra). This would be due to the applications either not having enough memory to open themselves (i.e. show their own windows) or not enough memory for their additional needs, such as editing files. If there are only 10,000 bytes of memory remaining and two newly opened applications are waiting for 50,000 bytes of memory each they will be put in a waiting queue. Waiting forever. Or at least until another application closes and releases its memory, but it might only be releasing 4000 bytes of memory. In which case one of the waiting applications could use the 4000 bytes now available and then wait for the other 46,000 bytes to become available.

On the other hand, the applications might get sick of waiting and decide to close. Either way it's a slow and messy process. This is why you should get to know the limits of your computer first before opening too many applications at once. Another scenario is memory corruption. Basically this is when an application misinterprets some byte values. For example: If a language program is supposed to read 74, in a settings (preferences) file, as English but sees (reads) 77 instead. It would probably show text in a different language - Not much harm as you could probably change the language setting (preference) back to English once the language application had opened and fully completed. However. Imagine if an application interprets a byte value of 100 to mean you have paid/registered to use that application and a byte value of 101 to mean you are just trying out that application for 30 days.

You might of paid £30 for an application that is saying you have not paid, but you are just trying it out. Incidently. This is one way hackers hack legal software...they change the application's data (byte values) so it thinks the user has paid for it. Apart from hacked bytes data is normally corrupted because the files (software/applications) came from a bad/scratched floppy disk or CD - The files can still be read as data (byte values), but as incorrect data. Unfortunately, an application will not test every byte value inside a file simply because it would take too long, especially if it was a large file.


The reason for explaining memory to you is so that you get some idea of how Data is stored and how memory is allocated. In the above examples I mentioned bytes in terms of thousands only (i.e. 4,000 and 50,000) so you could understand the examples quite easily. However, the reality is that applications and files have become bigger and bigger over the years, to the point where you no longer say a file is just a few thousand bytes long. Now a file can be millions of bytes in length.

The same applies to the computer. Years ago the memory inside it might have been a maximum of 32KB (32,768 bytes) whereas these days it must have a minimum of 1GB (1,073,741,824 bytes) inside it. KB (KiloByte), MB (MegaByte), GB (GigaByte) and TB (TeraByte) are Byte terminology (jargon), as below:

1 KiloByte
2 KiloBytes
1 MegaByte
2 MegaBytes
1 GigaByte
2 GigaBytes
1 TeraByte
2 TeraBytes
1 Byte
2 Bytes or more
1,024 Bytes
2,048 Bytes
1,024,000 Bytes
2,048,000 Bytes
1,024,000,000 Bytes
2,048,000,000 Bytes
1,024,000,000,000 Bytes
2,048,000,000,000 Bytes
KiloByte(s) is abbreviated to KB
To work out KiloBytes just devide or multiply Bytes by 1,024
MegaByte(s) is abbreviated to MB
To work out MegaBytes just devide or multiply Bytes by 1,024,000
GigaByte(s) is abbreviated to GB
To work out GigaBytes just devide or multiply Bytes by 1,024,000,000
TeraByte(s) is abbreviated to TB
To work out TeraBytes just devide or multiply Bytes by 1,024,000,000,000

Reading Bytes - WRITING BYTES

When data is being read (i.e. from a floppy disk) it is known as Reading the data (because it is being looked at) and when data has been read it is known as Read (because it has been looked at).

When data is being saved it is known as Writing the data (because it is being written onto something, such as: a floppy disk) and when data has been saved it is known as Written (because it has been written onto something, such as: a floppy disk).