TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  • Concepts of Memory Management in Operating System

    Memory Management ek essential function hai jo OS aur applications ke beech memory ko allocate aur deallocate karta hai. Iska main goal efficient memory utilization aur fast execution ensure karna hota hai.


    🔹 What is Memory Management?

    Memory Management ek process hai jo system ki memory ko manage karta hai, taki multiple processes efficiently execute ho sakein.

    💡 Key Functions of Memory Management:
    Process ko memory allocate karna aur free karna
    Memory fragmentation ko minimize karna
    CPU aur disk ke beech smooth data transfer ensure karna
    Virtual memory aur paging jaisi techniques ka use karna


    🔹 Types of Memory in Memory Management

    OS do types ki memory handle karta hai:

    1️⃣ Primary Memory (Main Memory)

    • RAM (Random Access Memory) jo CPU directly access karta hai.

    • Volatile Memory hoti hai, yani power off hone par data erase ho jata hai.

    • Fast but limited storage capacity hoti hai.

    Example: Jab aap ek game open karte ho, toh uska data temporarily RAM me store hota hai execution ke liye.


    2️⃣ Secondary Memory

    • Permanent storage ke liye HDD/SSD use hoti hai.

    • OS aur applications ka data yahan store hota hai.

    • Slow but large storage hoti hai.

    Example: Windows ka C:\ drive ek secondary storage hai jisme OS install hota hai.


    🔹 Memory Management Techniques

    1️⃣ Contiguous Memory Allocation

    • Ek process ko ek continuous block of memory allocate hota hai.

    • Memory fragmentation ka issue ho sakta hai.

    💡 Example:
    Agar RAM 100 MB hai aur process ko 30 MB chahiye, toh ek continuous 30 MB block allocate hoga. Agar chhoti-chhoti fragments bach jayein, toh kuch processes allocate nahi ho sakti.

    Solution: Compaction technique use karke free memory ko ek sath arrange kiya jata hai.


    2️⃣ Paging (Non-Contiguous Memory Allocation)

    • Memory ko fixed-size blocks (pages) me divide kiya jata hai.

    • Har process ko pages assign kiye jate hain jo RAM me kisi bhi location par store ho sakte hain.

    💡 Example:
    Agar RAM me scattered free spaces hain, toh process ke different pages alag-alag locations par store ho sakte hain, jisse memory fragmentation problem solve hoti hai.


    3️⃣ Segmentation

    • Memory ko variable-size segments me divide kiya jata hai.

    • Logical divisions jese Code, Data, Stack alag-alag segments me store hote hain.

    Example:
    Ek C program ka Code Segment, Data Segment aur Stack Segment alag-alag memory me store hota hai.


    4️⃣ Virtual Memory

    • Agar RAM full ho jaye, toh secondary storage ka ek part (swap space) use hota hai.

    • Paging aur demand paging ka use hota hai.

    💡 Example:
    Agar aapke system ki RAM 4GB hai aur aap 8GB ka software run karte hain, toh extra 4GB ka data HDD ke ek part (Page File) me store hoga.


    🔹 Memory Allocation Strategies

    First Fit: Pehla available block allocate hota hai.
    Best Fit: Sabse chhota possible block allocate hota hai.
    Worst Fit: Sabse bada block allocate hota hai.

    Example:
    Agar RAM me 100MB, 50MB aur 20MB ke free blocks hain aur ek process ko 18MB chahiye, toh:

    • First Fit: 20MB block milega.

    • Best Fit: 20MB block milega.

    • Worst Fit: 100MB block milega.


    🔹 Conclusion

    ✔ Memory Management OS ka critical function hai jo efficiency badhata hai.
    Paging, Segmentation aur Virtual Memory techniques system performance ko optimize karti hain.
    Best memory allocation technique choose karna system ki speed aur performance improve karta hai.

    Scroll to Top