I was writing a blog post about Clean Code and suddenly realized that although this website called freethemalloc.com, I have zero C/C++ , pointer or memory allocation content. I decided to talk about those starting with good old fashioned MEMORY.
Memory is a special operator in Computers, that needs to be specially managed by the Operating System
Most important places where memory is needed are:
- Source Codes and Data
For Operating System itself:
- OS – Source Code
- OS – Data
- Dynamically created management structures like PCB’s (not to be confused with PCB – electronics)
The Task of Memory Management
The operating system starts dealing with memory at the very beginning of system start:
- OS detects Location and Size of the whole memory
- OS detects its own position in memory
- Calculates free memory
How does OS reserve the memory usage?
- Memory: 0x0000 – 0x8000
- OS Code and Data: 0x0000 – 0x3000
- free space: 0x3000 – 0x8000
Now we want to allocate memory for a process. But how does the OS keeps track of it?