The physical memory is what we usually call the RAM (Random Access Memory). The memory is where programs are loaded when they are run. It is easier to access data in memory than to access data on disk. However, data in memory won’t stay there permanently. Once the program ends, it will be released. Once the computer goes off, it will vanish. It is volatile.
Blocks of data
The physical Memory can be viewed as block of spaces that can hold data. For the sake of explanation, let’s assume each block is 4 bytes (32 bits).
We precede hex values with 0x (So don’t get confused with the 0x you’re seeing).
Looking at the image above, each block is 32bits. 0 – 31, 32-63, that way. This means that when you run a program that needs to load 8 bytes of data into memory, it will begin to save that data from 0x000 to 0x003F covering two blocks (or from the highest downwards. We won’t go too deep into that).
Characters are 1 byte
A – Z, a-z, 0-9, and all symbols are characters. Each character is 8bits (1 byte) and is represented by a particular 8bit value. The American Standard Code for Information Interchange (ASCII) determines which character is represented by which 8bit value. For instance the ASCII code for ‘A’ is 01000001, 65 in decimal.
Since each character is 1 byte, if I have to load ‘John’ into memory, that will be 4bytes. Suppose Something already exists at the first block, then I may start from the second block 0x0020 and end at 0x003F, saving all 4bytes.
The hex numbers you see in the diagram, tells which block and which position in the physical memory data is located. It is the memory address. Suppose a program needs to retrieve data loaded into memory, the program does that using the memory address.
What to remember
If all this is too much to grasp, just keep in mind that in programming, your program loads and retrieve data from the memory. What ever is loaded or retrieved make use of memory blocks that have addresses they are accessed by.
It is important to keep memory usage at the back of your mind while you write programs.
In our next tutorial, we’ll start learning actual Python programming. If you have any comments, thoughts, questions, leave them in the comment box or submit them on the contact page. Enjoy!