Merits and demerits of static and dynamic memory allocation


Asked by admin @ in Science viewed by 315 People


Advantages and disadvantages of static and dynamic memory allocation

Answered by admin @



Static
allocation:


Advantages:


1.    Static
allocation is done at compile time when you know the size of the array.


2.    The
memory size allocated to “data” is static. But it is possible to change content
of a static structure without increasing the memory space allocated to it.


3.    Global
variables are declared “ahead of time,” such as fixed array.


4.    Lifetime
of Static allocation is the entire runtime of program.


5.    It
has efficient execution time


Disadvantages:


1.      In
case more static data space is declared than needed, there is waste of space.


2.    In
case less static space is declared than needed, then it becomes impossible to
expand this fixed size during run time.



Dynamic Allocation:


Advantages:


·        
 Dynamic Allocation
is done at run time.


·        
  Data structures can grow and shrink to fit
changing data requirements.


·        
 We can
allocate (create) additional storage whenever we need them.


·        
We can de-allocate (free/delete) dynamic space
whenever we are done with them.  


·        
Thus we can always have exactly the amount of
space required - no more, no less.


Disadvantages:


·        
As the memory is allocated during runtime, it requires more
time.


·        
Memory needs to be freed by the user when done. This is important as it is more likely to
turn into bugs that are difficult to find.



Similar Questions

Difference between static memory allocation and dynamic memory allocation

Asked by admin @ in Computer Science viewed by 259 persons

Differentiate between static and dynamic memory allocation

Transpose of a matrix in c using dynamic memory allocation

Asked by admin @ in Computer Science viewed by 300 persons

C program to find transpose of a matrix using dynamic memory allocation

What is the difference between dynamic stretching and static stretching

Asked by admin @ in Health viewed by 319 persons

Explain in at least 2 complete sentences the differences between dynamic stretching and static stretching.

What are the merits and demerits of democracy

Asked by admin @ in Social Sciences viewed by 286 persons

5 merits and demerits of democracy

What are the merits and demerits of electoral competition

Asked by admin @ in Social Sciences viewed by 295 persons

What are the merits and demerits of electoral competition?

What are the merits and demerits of green revolution

Asked by admin @ in Economy viewed by 284 persons

Explain the merits and demerits of the Green Revolution.

Dynamic friction as compared to static friction is

Asked by admin @ in Physics viewed by 325 persons

Dynamic friction as compared to static friction is (a) same (b) more (c) less (d) may be less of more depending on nature of surfaces and velocity

Explain two merits and three demerits of green revolution

Asked by admin @ in Economy viewed by 318 persons

Explain the merits and demerits of the Green Revolution.

List the merits and demerits of coalition government in india

Asked by admin @ in Social Sciences viewed by 339 persons

What is a coalition government? List the Merits and Demerits of this type of government in a country like India. pls please pls tell the answer.....​

Overcoming fixed mindset: a step-by-step guide to cultivating a growth mindset

Asked by wiki @ in Health viewed by 1346 persons

Which of the following would best complete this list?

Asked by wiki @ in Social Studies viewed by 787 persons

What had the king decided to do before he saw the spider

Asked by vanshika149 @ in English viewed by 1200 persons

Describe the karez in your own words

Asked by rajesh064 @ in English viewed by 1374 persons

What is 8 + (x + 5)?

Asked by jaylord7 @ in Mathematics viewed by 1148 persons

Most viewed questions in Science


Vikas science and technology experiment book std 10 answers

Asked by admin @ in Science viewed by 6208 persons


Rpa focuses on ease of use by reducing human dependency

Asked by admin @ in Science viewed by 4825 persons


Which scenario best illustrates the implementation of data governance

Asked by admin @ in Science viewed by 3906 persons



Collect metal vessels and various metal articles write detailed information

Asked by admin @ in Science viewed by 3841 persons


Britannica learning the english channel class 5 solutions pdf

Asked by admin @ in Science viewed by 3286 persons


Abdul while driving to school computes the average speed

Asked by admin @ in Science viewed by 2275 persons



Vet in the forest class 7 questions and answers

Asked by admin @ in Science viewed by 2055 persons


Rpa is capable of learning and responding to new situations

Asked by admin @ in Science viewed by 1765 persons


Born to express not to impress meaning in tamil

Asked by admin @ in Science viewed by 1613 persons



Why do we fall ill class 9 mind map

Asked by admin @ in Science viewed by 1452 persons


Vikas science and technology experiment book std 10 pdf

Asked by admin @ in Science viewed by 1340 persons


Which of the following statements regarding electrical safety is correct

Asked by admin @ in Science viewed by 1308 persons



Oxford new science in everyday life class 5 solutions

Asked by admin @ in Science viewed by 1264 persons


Born to express not to impress meaning in marathi

Asked by admin @ in Science viewed by 1252 persons


This fish changes colour to merge with its background

Asked by admin @ in Science viewed by 1120 persons