Computer Science

FreetheMalloc Special – Chapter 1: Computer Memory: Memory Management

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:

For processes:

  • Stack
  • Heap
  • 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:

  1. OS detects Location and Size of the whole memory
  2. OS detects its own position in memory
  3. Calculates free memory

Quick Note:

How does OS reserve the memory usage?

Example:

  • 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?

Leave a Reply

Your email address will not be published. Required fields are marked *