Memory Management in Operating System

 What is Main Memory

 Main memory, also called RAM, is where a computer keeps data and programs that the CPU is currently using. It’s fast and temporary; data is lost when the power is off.

What is Memory Management

 Memory management is how an operating system handles memory for different programs. It makes sure memory is used efficiently and helps avoid problems like memory waste or fragmentation.

Why It's Needed:

  • Allocates memory before processes start and frees it afterward.
  • Keeps track of which memory is used.
  • Reduces memory waste (fragmentation).
  • Ensures memory is used effectively and data stays safe during processing.

Logical vs. Physical Address:

  • Logical Address: The address made by the CPU, which can change.
  • Physical Address: The actual address in memory, which stays the same.






Static vs. Dynamic Loading:

  • Static Loading: Loads the whole program at once, using more memory.
  • Dynamic Loading: Only loads parts of the program when needed, saving memory.
Watch this video for more on it:



Static vs. Dynamic Linking:



  • Static Linking: Combines all program parts into one, with no dependencies at runtime.
  • Dynamic Linking: Uses small pieces of code that load program parts only when needed.

Swapping:
Swapping moves programs between main memory and secondary memory to manage multiple tasks. It allows more programs to run by temporarily moving less important ones out of the way.




Memory Management Without Swapping:
This simple approach divides memory into two parts: one for the operating system and one for user programs. It’s easy but doesn’t support running multiple programs at once, leading to wasted memory.

Fixed Partitions (Without Swapping):
Memory is divided into fixed-sized blocks for different programs. This helps run multiple programs but can be inefficient if the blocks don’t match the program sizes.


Fragmentation:
Fragmentation happens when memory is wasted due to small gaps (internal) or when memory isn’t in a continuous block (external). It’s a problem that reduces the efficiency of memory use.



Paging:
Paging breaks memory into smaller, fixed-size pages that don’t need to be next to each other. This helps avoid the issues with fragmentation and makes better use of memory.



Comments

  1. I like where you’re going with this, but I feel like you missed a key point.

    ReplyDelete
  2. Can you give a real word example of fragmantation, i dont get it.

    ReplyDelete
  3. I can tell you put a lot of thought into this.

    ReplyDelete

Post a Comment

Popular posts from this blog

Thread in Operating System