SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
CD
DynamicStorage
AllocationTechniques
Kunjan Shah
170410107103
LY CE 2
Batch C
Dynamic
Memory
Allocation
 Those cases where the input isn’t known beforehand, we suffer in terms
of inefficient storage use and lack or excess of slots to enter data (given
an array or similar data structures to store entries). So, we define
Dynamic Memory Allocation.
 Memory is allocated during the execution of the program.
 It leads to better memory utilization i.e. there is no wastage of memory.
 Allocated only when program unit is active.
 This dynamic memory allocation is generally used for linked list.
 It uses heap for managing the dynamic allocation of memory.
Dynamic
Memory
Allocation
 Two techniques are used in DMA:
1. Explicit allocation
2. Implicit allocation
oExplicit allocation is the kind of memory allocation that can be
done with the help of some procedures.
o For example – In PASCAL the memory allocation is done using
new function and deallocation is done using dispose function.
 Implicit allocation is a kind of allocation that can be done
automatically by the compiler using run time support packages.
Explicit
allocation
 The explicit allocation can be done for fixed size and variable sized blocks.
Explicit Allocation for FixedSize Blocks
 This is the simplest technique of explicit allocation in which the size of the block
for which memory is allocated is fixed.
 In this technique a free list is used. Free list is a set of free blocks.This observed
when we want to allocate memory. If some memory is de-allocated then the
free list gets added.
 The blocks are linked to each other in a list structure.The memory allocation can
be done by pointing previous node to the newly allocated block. Memory
deallocation can be done by dereferencing the pervious link.
 Pointer which points to first block is called Available.
 Memory allocation and deallocation is done by using heap memory.
 Advantage is that there is no space overhead.
Explicit
allocation
Explicit
allocation
Explicit Allocation for Variable Size Blocks
 Due to frequent memory allocation and deallocation the heap
memory becomes fragmented.That means heap may consist of
some blocks that are free and some that are allocated. In short,
not proper memory utilization.
 Suppose a list of 7 blocks get allocated and 2, 4 and 6 is
deallocated then fragmentation occurs.Thus we get variable sized
blocks that are available free.
Explicit
allocation
Explicit Allocation for Variable Size Blocks
 For allocating variable sized blocks some strategies such as first
fit, worst fit and best fit are used.When a block of size S is
allocated and if we search for the free block in the heap and the
first available free block whose size > S is used then it is called first
fit.
 Sometimes all free blocks are collected together to form a larger
free block.This ultimately avoids the problem of fragmentation.
Implicit
allocation
 Performed using user program
and runtime packages.
 The run time package is
required to know when the
storage block is not in use.
Implicit
allocation
 Two problems mainly:
1. Recognizing block boundaries. If the block size is fixed then user
data can be easily accessible.
2. To determine which block is in use.
 Two approaches is used for implicit allocation:
1. Reference count - It is a special counter used during implicit
memory allocation. If any block is referred by some another block
then its reference count incremented by one.That also means if the
reference count of particular block drops down to 0 then, that
means that block isn’t referenced one and hence it can be de-
allocated.
Implicit
allocation
 Two approaches is used for implicit allocation:
2. Marking techniques –This an alternative approach to determine
whether the block is in use or not. In this method, the user program is
suspended temporarily and pointers are used to mark the blocks that are
in use. Sometime bitmaps are used. Bitmaps are used to mark the blocks
which are in use. A bit-table stores all the bits.This table indicates the
blocks which are in use currently.
These pointers are then placed in the heap memory. Again we go
through heap memory and mark those blocks which are unused.
Thus using marking technique it is possible to keep track of the blocks
that are in use.
By marking we can determine, which blocks are used and which are not .
Dynamic storage allocation techniques in Compiler design

More Related Content

What's hot (20)

PPTX
File Management in Operating System
Janki Shah
 
PDF
Memory Management
DEDE IRYAWAN
 
PPTX
Message passing in Distributed Computing Systems
Alagappa Govt Arts College, Karaikudi
 
PPTX
Pipelining and vector processing
Kamal Acharya
 
PPTX
Lect4 software economics
meena466141
 
PPTX
DeadLock in Operating-Systems
Venkata Sreeram
 
PPTX
Memory Management in OS
Kumar Pritam
 
PPTX
Dynamic storage allocation techniques
Shashwat Shriparv
 
PPTX
Structure of shared memory space
Coder Tech
 
PPTX
File allocation methods (1)
Dr. Jasmine Beulah Gnanadurai
 
DOC
Distributed Mutual exclusion algorithms
MNM Jain Engineering College
 
PPTX
Unit 4 sp macro
Deepmala Sharma
 
PPT
cache memory
NAHID HASAN
 
PDF
Disk allocation methods
ajeela mushtaq
 
PPT
Communication primitives
Student
 
PPTX
2. Distributed Systems Hardware & Software concepts
Prajakta Rane
 
PPTX
Free Space Management, Efficiency & Performance, Recovery and NFS
United International University
 
PPTX
Pci,usb,scsi bus
Sherwin Rodrigues
 
PDF
Mobile computing (Wireless) Medium Access Control (MAC)
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPTX
Cache memory ppt
Arpita Naik
 
File Management in Operating System
Janki Shah
 
Memory Management
DEDE IRYAWAN
 
Message passing in Distributed Computing Systems
Alagappa Govt Arts College, Karaikudi
 
Pipelining and vector processing
Kamal Acharya
 
Lect4 software economics
meena466141
 
DeadLock in Operating-Systems
Venkata Sreeram
 
Memory Management in OS
Kumar Pritam
 
Dynamic storage allocation techniques
Shashwat Shriparv
 
Structure of shared memory space
Coder Tech
 
File allocation methods (1)
Dr. Jasmine Beulah Gnanadurai
 
Distributed Mutual exclusion algorithms
MNM Jain Engineering College
 
Unit 4 sp macro
Deepmala Sharma
 
cache memory
NAHID HASAN
 
Disk allocation methods
ajeela mushtaq
 
Communication primitives
Student
 
2. Distributed Systems Hardware & Software concepts
Prajakta Rane
 
Free Space Management, Efficiency & Performance, Recovery and NFS
United International University
 
Pci,usb,scsi bus
Sherwin Rodrigues
 
Mobile computing (Wireless) Medium Access Control (MAC)
Jyothishmathi Institute of Technology and Science Karimnagar
 
Cache memory ppt
Arpita Naik
 

Similar to Dynamic storage allocation techniques in Compiler design (20)

PPTX
Memory Management in Linux-.ppt|FREE DOWNLOAD
faizanayub16
 
PPTX
Memory allocation for real time operating system
Asma'a Lafi
 
PPT
Memory allocation (4)
rockymani
 
PPTX
Memory concept and managementChapter 3.pptx
natyesu
 
PPT
IS 139 Lecture 7
wajanga
 
PPTX
Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
AkhilMishra50
 
PPTX
Dynamic Memory & Linked Lists
Afaq Mansoor Khan
 
PPTX
Cache.pptx
VCETCSE
 
PPTX
Heap Memory Management.pptx
Viji B
 
PPT
chapter 6 memory computer architecture.ppt
adedeji0110
 
PPT
Os7
issbp
 
PPTX
Cache Memory.pptx
ssusere16bd9
 
PPTX
local_media3192961381667787861026781.pptx
Lyn B
 
PPTX
File Allocation methods in Operating Systems
jdatta247
 
PPTX
Dynamic memory allocation
Gaurav Mandal
 
PPTX
memory management IN OS ANURAG PATE.pptx
SHARMA ONLINE
 
PDF
Analysis of Allocation Algorithms in Memory Management
ijtsrd
 
PDF
Memory Management in Go: Stack, Heap & Garbage Collector
Wednesday Solutions
 
PDF
Dynamic loading
A. S. M. Shafi
 
PPTX
CPU Caching Concepts
Abhijit K Rao
 
Memory Management in Linux-.ppt|FREE DOWNLOAD
faizanayub16
 
Memory allocation for real time operating system
Asma'a Lafi
 
Memory allocation (4)
rockymani
 
Memory concept and managementChapter 3.pptx
natyesu
 
IS 139 Lecture 7
wajanga
 
Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
AkhilMishra50
 
Dynamic Memory & Linked Lists
Afaq Mansoor Khan
 
Cache.pptx
VCETCSE
 
Heap Memory Management.pptx
Viji B
 
chapter 6 memory computer architecture.ppt
adedeji0110
 
Os7
issbp
 
Cache Memory.pptx
ssusere16bd9
 
local_media3192961381667787861026781.pptx
Lyn B
 
File Allocation methods in Operating Systems
jdatta247
 
Dynamic memory allocation
Gaurav Mandal
 
memory management IN OS ANURAG PATE.pptx
SHARMA ONLINE
 
Analysis of Allocation Algorithms in Memory Management
ijtsrd
 
Memory Management in Go: Stack, Heap & Garbage Collector
Wednesday Solutions
 
Dynamic loading
A. S. M. Shafi
 
CPU Caching Concepts
Abhijit K Rao
 
Ad

More from kunjan shah (6)

PPTX
Error detection techniques
kunjan shah
 
PPTX
Multidimensional schema of data warehouse
kunjan shah
 
PPT
season management in php (WT)
kunjan shah
 
PPTX
Web browser and web servers (WT)
kunjan shah
 
PPTX
Decision and looping examples with php (WT)
kunjan shah
 
PPTX
Generic view of software engineering SE
kunjan shah
 
Error detection techniques
kunjan shah
 
Multidimensional schema of data warehouse
kunjan shah
 
season management in php (WT)
kunjan shah
 
Web browser and web servers (WT)
kunjan shah
 
Decision and looping examples with php (WT)
kunjan shah
 
Generic view of software engineering SE
kunjan shah
 
Ad

Recently uploaded (20)

PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 

Dynamic storage allocation techniques in Compiler design

  • 2. Dynamic Memory Allocation  Those cases where the input isn’t known beforehand, we suffer in terms of inefficient storage use and lack or excess of slots to enter data (given an array or similar data structures to store entries). So, we define Dynamic Memory Allocation.  Memory is allocated during the execution of the program.  It leads to better memory utilization i.e. there is no wastage of memory.  Allocated only when program unit is active.  This dynamic memory allocation is generally used for linked list.  It uses heap for managing the dynamic allocation of memory.
  • 3. Dynamic Memory Allocation  Two techniques are used in DMA: 1. Explicit allocation 2. Implicit allocation oExplicit allocation is the kind of memory allocation that can be done with the help of some procedures. o For example – In PASCAL the memory allocation is done using new function and deallocation is done using dispose function.  Implicit allocation is a kind of allocation that can be done automatically by the compiler using run time support packages.
  • 4. Explicit allocation  The explicit allocation can be done for fixed size and variable sized blocks. Explicit Allocation for FixedSize Blocks  This is the simplest technique of explicit allocation in which the size of the block for which memory is allocated is fixed.  In this technique a free list is used. Free list is a set of free blocks.This observed when we want to allocate memory. If some memory is de-allocated then the free list gets added.  The blocks are linked to each other in a list structure.The memory allocation can be done by pointing previous node to the newly allocated block. Memory deallocation can be done by dereferencing the pervious link.  Pointer which points to first block is called Available.  Memory allocation and deallocation is done by using heap memory.  Advantage is that there is no space overhead.
  • 6. Explicit allocation Explicit Allocation for Variable Size Blocks  Due to frequent memory allocation and deallocation the heap memory becomes fragmented.That means heap may consist of some blocks that are free and some that are allocated. In short, not proper memory utilization.  Suppose a list of 7 blocks get allocated and 2, 4 and 6 is deallocated then fragmentation occurs.Thus we get variable sized blocks that are available free.
  • 7. Explicit allocation Explicit Allocation for Variable Size Blocks  For allocating variable sized blocks some strategies such as first fit, worst fit and best fit are used.When a block of size S is allocated and if we search for the free block in the heap and the first available free block whose size > S is used then it is called first fit.  Sometimes all free blocks are collected together to form a larger free block.This ultimately avoids the problem of fragmentation.
  • 8. Implicit allocation  Performed using user program and runtime packages.  The run time package is required to know when the storage block is not in use.
  • 9. Implicit allocation  Two problems mainly: 1. Recognizing block boundaries. If the block size is fixed then user data can be easily accessible. 2. To determine which block is in use.  Two approaches is used for implicit allocation: 1. Reference count - It is a special counter used during implicit memory allocation. If any block is referred by some another block then its reference count incremented by one.That also means if the reference count of particular block drops down to 0 then, that means that block isn’t referenced one and hence it can be de- allocated.
  • 10. Implicit allocation  Two approaches is used for implicit allocation: 2. Marking techniques –This an alternative approach to determine whether the block is in use or not. In this method, the user program is suspended temporarily and pointers are used to mark the blocks that are in use. Sometime bitmaps are used. Bitmaps are used to mark the blocks which are in use. A bit-table stores all the bits.This table indicates the blocks which are in use currently. These pointers are then placed in the heap memory. Again we go through heap memory and mark those blocks which are unused. Thus using marking technique it is possible to keep track of the blocks that are in use. By marking we can determine, which blocks are used and which are not .