SlideShare a Scribd company logo
RUN-TIME
ENVIRONMENTSHEAP MANAGAGEMENT
HEAP
- portion of the store used for data that lives
indefinitely or until explicitly deleted by the
program
Nevermore by Paul
Gaugin
MEMORY MANAGER
 the subsystem that allocates and
deallocates space within the heap
 keeps track of all the free space in heap
storage at all times
 serves as an interface between
application programs and the operating
system
MEMORY MANAGER
 produces a chunk of contiguous heap
memory of the requested size
 if no chunk of the needed size is
available, it increases the heap storage
by getting consecutive bytes of virtual
memory from the OS
ALLOCATION
MEMORY
ALLOCATION
 returns deallocated space to the pool of
free space (so it can reuse the space)
 typically does not return memory to the
OS, even if heap usage drops
DEALLOCATION
MEMORY
ALLOCATION
 Space Efficiency
 Program Efficiency
 Low Overhead
MEMORY MANAGER
WINTERTemplate
MEMORY
HIERARCHY
01
02
Register
1st-Level
Cache
2nd-Level Cache
Physical Memory
Virtual Memory (Disk)
Memory Diagram
Typical Sizes
32 Words
16 - 64KB
128KB - 4MB
256MB - 2GB
> 2GB
Typical Access Times
1 ns
5 - 10 ns
40 - 60 ns
100 - 150 ns
3 - 15 ms
02Memory Diagram
Register
1st-Level
Cache
2nd-Level Cache
Physical Memory
Virtual Memory (Disk)
The goal is to obtain
the best average
access speed while
minimizing the total
cost of the entire
memory system.
03Principle of Locality
Also known as Locality of Reference
The phenomenon of the same value or
related storage locations being frequently
accessed.
90/10 Rule comes
from the empirical
observation:
“A program spends
90% of its time in
10% of its code.”
03
Two Types of Access Locality
1. Temporal Locality
2. Spatial Locality
Principle of Locality
03
1. Temporal Locality
the memory locations the program
accesses are likely to be accessed again
within a short period of time
Principle of Locality
Example: Instruction in the
body of inner loops
03
2. Spatial Locality
memory locations close to the location
accessed are likely also to be accessed
within a short period of time
Principle of Locality
Example: Traversing the
elements in a one-dimentional
array
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition,
Reducing Fragmentation
8.16 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition
CONTIGUOUS MEMORY
8.17 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition
Contiguous Allocation
 Main memory usually into two partitions:
 Resident operating system, usually held in low memory
with interrupt vector
 User processes then held in high memory
8.18 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition
Contiguous Allocation
 Hole – block of available memory; holes of various size are
scattered throughout memory
 When a process arrives, it is allocated memory from a hole
large enough to accommodate it
 Operating system maintains information about:
a) allocated partitions b) free partitions (hole)
OS
process 5
process 8
process 2
OS
process 5
process 2
OS
process 5
process 2
OS
process 5
process 9
process 2
process 9
process 10
8.19 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition
Dynamic Storage-Allocation Problem
 First-fit: Allocate the first hole that is big enough
 Best-fit: Allocate the smallest hole that is big enough; must
search entire list, unless ordered by size
 Produces the smallest leftover hole
 Worst-fit: Allocate the largest hole; must also search entire
list
 Produces the largest leftover hole
How to satisfy a request of size n from a list of free holes
 Coalescing
REDUCING FRAGMENTATION
COALESCING
- combining adjacent chunks of the heap to
form a larger chunk
 Boundary Tags
- keeping a free/used bit at both ends of each
chunk
- adjacent to the free/used bit is a count of
the # of bytes
 Doubly Linked, Imbedded Free List
- free chunks are linked in a doubly linked list
- chunks must accommodate two boundary
tags and two pointers
COALESCING
REDUCING
FRAGMENTATION
MANUAL DEALLOCATION
REQUEST
 Memory-leak Error
- failing to EVER delete data that cannot be
referenced
 Dangling-pointer-dereference
[note: dangling pointers - pointers to storage that
has
been deallocated]
- referencing deleted data
MANUAL DEALLOCATION
REQUESTS
 Object Ownership
- associate an owner with each object (e.g.
functions and their variables)
 Reference Counting
- associate a count with each dynamically
allocated object
PROGRAMMING CONVENTIONS &
TOOLS
MANUAL DEALLOCATION
REQUESTS
 Region-based Allocation
- allocate all objects in the same region; then
delete the entire region
PROGRAMMING CONVENTIONS &
TOOLS
MANUAL DEALLOCATION
REQUESTS
Fin.

More Related Content

What's hot

Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
NEERAJ BAGHEL
 
Operating system 32 logical versus physical address
Operating system 32 logical versus physical addressOperating system 32 logical versus physical address
Operating system 32 logical versus physical address
Vaibhav Khanna
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Context model
Context modelContext model
Context model
Ubaid423
 
Message passing in Distributed Computing Systems
Message passing in Distributed Computing SystemsMessage passing in Distributed Computing Systems
Message passing in Distributed Computing Systems
Alagappa Govt Arts College, Karaikudi
 
Demand paging
Demand pagingDemand paging
Demand paging
Trinity Dwarka
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
Iffat Anjum
 
Distributed shred memory architecture
Distributed shred memory architectureDistributed shred memory architecture
Distributed shred memory architecture
Maulik Togadiya
 
Pass Structure of Assembler
Pass Structure of AssemblerPass Structure of Assembler
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
Kalaimathi Vijayakumar
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
Satyamevjayte Haxor
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMSkoolkampus
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
Darshan sai Reddy
 
Underlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computingUnderlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computing
GOVERNMENT COLLEGE OF ENGINEERING,TIRUNELVELI
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
Mazin Alwaaly
 
Product Cipher
Product CipherProduct Cipher
Product Cipher
SHUBHA CHATURVEDI
 
Address in the target code in Compiler Construction
Address in the target code in Compiler ConstructionAddress in the target code in Compiler Construction
Address in the target code in Compiler Construction
Muhammad Haroon
 
File models and file accessing models
File models and file accessing modelsFile models and file accessing models
File models and file accessing models
ishmecse13
 
Heap management in Compiler Construction
Heap management in Compiler ConstructionHeap management in Compiler Construction
Heap management in Compiler Construction
Muhammad Haroon
 

What's hot (20)

Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
Operating system 32 logical versus physical address
Operating system 32 logical versus physical addressOperating system 32 logical versus physical address
Operating system 32 logical versus physical address
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Context model
Context modelContext model
Context model
 
Message passing in Distributed Computing Systems
Message passing in Distributed Computing SystemsMessage passing in Distributed Computing Systems
Message passing in Distributed Computing Systems
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Distributed shred memory architecture
Distributed shred memory architectureDistributed shred memory architecture
Distributed shred memory architecture
 
Pass Structure of Assembler
Pass Structure of AssemblerPass Structure of Assembler
Pass Structure of Assembler
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
 
Underlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computingUnderlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computing
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
 
Product Cipher
Product CipherProduct Cipher
Product Cipher
 
Address in the target code in Compiler Construction
Address in the target code in Compiler ConstructionAddress in the target code in Compiler Construction
Address in the target code in Compiler Construction
 
Stepwise planning
Stepwise planningStepwise planning
Stepwise planning
 
File models and file accessing models
File models and file accessing modelsFile models and file accessing models
File models and file accessing models
 
Heap management in Compiler Construction
Heap management in Compiler ConstructionHeap management in Compiler Construction
Heap management in Compiler Construction
 

Similar to Heap Management

Operating System
Operating SystemOperating System
Operating System
Subhasis Dash
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
Prashanth Kumar
 
Contiguous Memory Allocation.ppt
Contiguous Memory Allocation.pptContiguous Memory Allocation.ppt
Contiguous Memory Allocation.ppt
infomerlin
 
Unit iiios Storage Management
Unit iiios Storage ManagementUnit iiios Storage Management
Unit iiios Storage Management
donny101
 
ch8-1 (final Memory).pptx
ch8-1 (final Memory).pptxch8-1 (final Memory).pptx
ch8-1 (final Memory).pptx
AnamRiaz31
 
Cache memory and cache
Cache memory and cacheCache memory and cache
Cache memory and cache
VISHAL DONGA
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OSC.U
 
Memory allocation for real time operating system
Memory allocation for real time operating systemMemory allocation for real time operating system
Memory allocation for real time operating systemAsma'a Lafi
 
CH08.pdf
CH08.pdfCH08.pdf
CH08.pdf
ImranKhan880955
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1rohassanie
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
Johan Granados Montero
 
Bab 4
Bab 4Bab 4
Bab 4
n k
 
Linux memorymanagement
Linux memorymanagementLinux memorymanagement
Linux memorymanagement
pradeepelinux
 
Cache Memory.pptx
Cache Memory.pptxCache Memory.pptx
Cache Memory.pptx
ssusere16bd9
 
CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3
Kathirvel Ayyaswamy
 
Main Memory
Main MemoryMain Memory
Main Memory
Jenny Galino
 
Google File System
Google File SystemGoogle File System
Google File System
DreamJobs1
 
Heap Memory Management.pptx
Heap Memory Management.pptxHeap Memory Management.pptx
Heap Memory Management.pptx
Viji B
 
Memory management OS
Memory management OSMemory management OS
Memory management OS
UmeshchandraYadav5
 

Similar to Heap Management (20)

Operating System
Operating SystemOperating System
Operating System
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
 
Contiguous Memory Allocation.ppt
Contiguous Memory Allocation.pptContiguous Memory Allocation.ppt
Contiguous Memory Allocation.ppt
 
Unit iiios Storage Management
Unit iiios Storage ManagementUnit iiios Storage Management
Unit iiios Storage Management
 
ch8-1 (final Memory).pptx
ch8-1 (final Memory).pptxch8-1 (final Memory).pptx
ch8-1 (final Memory).pptx
 
Cache memory and cache
Cache memory and cacheCache memory and cache
Cache memory and cache
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
 
Memory allocation for real time operating system
Memory allocation for real time operating systemMemory allocation for real time operating system
Memory allocation for real time operating system
 
CH08.pdf
CH08.pdfCH08.pdf
CH08.pdf
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
Bab 4
Bab 4Bab 4
Bab 4
 
Linux memorymanagement
Linux memorymanagementLinux memorymanagement
Linux memorymanagement
 
Cache Memory.pptx
Cache Memory.pptxCache Memory.pptx
Cache Memory.pptx
 
CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3
 
Main Memory
Main MemoryMain Memory
Main Memory
 
Google File System
Google File SystemGoogle File System
Google File System
 
Heap Memory Management.pptx
Heap Memory Management.pptxHeap Memory Management.pptx
Heap Memory Management.pptx
 
Memory management OS
Memory management OSMemory management OS
Memory management OS
 
Main memory-2 (ch8,os)
Main memory-2 (ch8,os)Main memory-2 (ch8,os)
Main memory-2 (ch8,os)
 

More from Jenny Galino

Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
Jenny Galino
 
Semantic Networks
Semantic NetworksSemantic Networks
Semantic Networks
Jenny Galino
 
Upper OSI Layers
Upper OSI LayersUpper OSI Layers
Upper OSI Layers
Jenny Galino
 
Genetically Modified Food
Genetically Modified FoodGenetically Modified Food
Genetically Modified Food
Jenny Galino
 
Geometry
GeometryGeometry
Geometry
Jenny Galino
 
Hierarchical Memory System
Hierarchical Memory SystemHierarchical Memory System
Hierarchical Memory System
Jenny Galino
 

More from Jenny Galino (7)

Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
 
Semantic Networks
Semantic NetworksSemantic Networks
Semantic Networks
 
Upper OSI Layers
Upper OSI LayersUpper OSI Layers
Upper OSI Layers
 
Genetically Modified Food
Genetically Modified FoodGenetically Modified Food
Genetically Modified Food
 
Geometry
GeometryGeometry
Geometry
 
Hierarchical Memory System
Hierarchical Memory SystemHierarchical Memory System
Hierarchical Memory System
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 

Recently uploaded

一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
peuce
 
web-tech-lab-manual-final-abhas.pdf. Jer
web-tech-lab-manual-final-abhas.pdf. Jerweb-tech-lab-manual-final-abhas.pdf. Jer
web-tech-lab-manual-final-abhas.pdf. Jer
freshgammer09
 
MATHEMATICS BRIDGE COURSE (TEN DAYS PLANNER) (FOR CLASS XI STUDENTS GOING TO ...
MATHEMATICS BRIDGE COURSE (TEN DAYS PLANNER) (FOR CLASS XI STUDENTS GOING TO ...MATHEMATICS BRIDGE COURSE (TEN DAYS PLANNER) (FOR CLASS XI STUDENTS GOING TO ...
MATHEMATICS BRIDGE COURSE (TEN DAYS PLANNER) (FOR CLASS XI STUDENTS GOING TO ...
PinkySharma900491
 
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Peter Gallagher
 
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
andreassenrolf537
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
aozcue
 
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
aozcue
 

Recently uploaded (7)

一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
 
web-tech-lab-manual-final-abhas.pdf. Jer
web-tech-lab-manual-final-abhas.pdf. Jerweb-tech-lab-manual-final-abhas.pdf. Jer
web-tech-lab-manual-final-abhas.pdf. Jer
 
MATHEMATICS BRIDGE COURSE (TEN DAYS PLANNER) (FOR CLASS XI STUDENTS GOING TO ...
MATHEMATICS BRIDGE COURSE (TEN DAYS PLANNER) (FOR CLASS XI STUDENTS GOING TO ...MATHEMATICS BRIDGE COURSE (TEN DAYS PLANNER) (FOR CLASS XI STUDENTS GOING TO ...
MATHEMATICS BRIDGE COURSE (TEN DAYS PLANNER) (FOR CLASS XI STUDENTS GOING TO ...
 
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
 
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
欧洲杯冠军-欧洲杯冠军网站-欧洲杯冠军|【​网址​🎉ac123.net🎉​】领先全球的买球投注平台
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证如何办理
 
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
 

Heap Management

  • 2. HEAP - portion of the store used for data that lives indefinitely or until explicitly deleted by the program Nevermore by Paul Gaugin
  • 4.  the subsystem that allocates and deallocates space within the heap  keeps track of all the free space in heap storage at all times  serves as an interface between application programs and the operating system MEMORY MANAGER
  • 5.  produces a chunk of contiguous heap memory of the requested size  if no chunk of the needed size is available, it increases the heap storage by getting consecutive bytes of virtual memory from the OS ALLOCATION MEMORY ALLOCATION
  • 6.  returns deallocated space to the pool of free space (so it can reuse the space)  typically does not return memory to the OS, even if heap usage drops DEALLOCATION MEMORY ALLOCATION
  • 7.  Space Efficiency  Program Efficiency  Low Overhead MEMORY MANAGER
  • 9. 02 Register 1st-Level Cache 2nd-Level Cache Physical Memory Virtual Memory (Disk) Memory Diagram Typical Sizes 32 Words 16 - 64KB 128KB - 4MB 256MB - 2GB > 2GB Typical Access Times 1 ns 5 - 10 ns 40 - 60 ns 100 - 150 ns 3 - 15 ms
  • 10. 02Memory Diagram Register 1st-Level Cache 2nd-Level Cache Physical Memory Virtual Memory (Disk) The goal is to obtain the best average access speed while minimizing the total cost of the entire memory system.
  • 11. 03Principle of Locality Also known as Locality of Reference The phenomenon of the same value or related storage locations being frequently accessed. 90/10 Rule comes from the empirical observation: “A program spends 90% of its time in 10% of its code.”
  • 12. 03 Two Types of Access Locality 1. Temporal Locality 2. Spatial Locality Principle of Locality
  • 13. 03 1. Temporal Locality the memory locations the program accesses are likely to be accessed again within a short period of time Principle of Locality Example: Instruction in the body of inner loops
  • 14. 03 2. Spatial Locality memory locations close to the location accessed are likely also to be accessed within a short period of time Principle of Locality Example: Traversing the elements in a one-dimentional array
  • 15. Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition, Reducing Fragmentation
  • 16. 8.16 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition CONTIGUOUS MEMORY
  • 17. 8.17 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition Contiguous Allocation  Main memory usually into two partitions:  Resident operating system, usually held in low memory with interrupt vector  User processes then held in high memory
  • 18. 8.18 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition Contiguous Allocation  Hole – block of available memory; holes of various size are scattered throughout memory  When a process arrives, it is allocated memory from a hole large enough to accommodate it  Operating system maintains information about: a) allocated partitions b) free partitions (hole) OS process 5 process 8 process 2 OS process 5 process 2 OS process 5 process 2 OS process 5 process 9 process 2 process 9 process 10
  • 19. 8.19 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition Dynamic Storage-Allocation Problem  First-fit: Allocate the first hole that is big enough  Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size  Produces the smallest leftover hole  Worst-fit: Allocate the largest hole; must also search entire list  Produces the largest leftover hole How to satisfy a request of size n from a list of free holes
  • 21. COALESCING - combining adjacent chunks of the heap to form a larger chunk
  • 22.  Boundary Tags - keeping a free/used bit at both ends of each chunk - adjacent to the free/used bit is a count of the # of bytes  Doubly Linked, Imbedded Free List - free chunks are linked in a doubly linked list - chunks must accommodate two boundary tags and two pointers COALESCING REDUCING FRAGMENTATION
  • 24.  Memory-leak Error - failing to EVER delete data that cannot be referenced  Dangling-pointer-dereference [note: dangling pointers - pointers to storage that has been deallocated] - referencing deleted data MANUAL DEALLOCATION REQUESTS
  • 25.  Object Ownership - associate an owner with each object (e.g. functions and their variables)  Reference Counting - associate a count with each dynamically allocated object PROGRAMMING CONVENTIONS & TOOLS MANUAL DEALLOCATION REQUESTS
  • 26.  Region-based Allocation - allocate all objects in the same region; then delete the entire region PROGRAMMING CONVENTIONS & TOOLS MANUAL DEALLOCATION REQUESTS
  • 27. Fin.