Blog‎ > ‎Blog Posts‎ > ‎

Static and Dynamic Memory Allocation…?

posted Jul 31, 2017, 8:24 AM by Rohit Bhaskar   [ updated Jul 31, 2017, 11:44 AM ]

Another post important for Computer Science students….And obviously for everyone else who is interested in such stuff.

Today’s post is really easy to understand and really important at the same time. The post covers what memory allocation is, why it is necessary and what are the differences between static and dynamic memory allocation.

Now, what does memory allocation mean?? Memory allocation is the process by which any process or program is allocated a certain portion of virtual or physical memory space. (Virtual memory space is nothing but the temporary memory generated in the RAM by moving files from it). If you did not understand this, just know that every process needs to use memory, and giving the process the memory it needs is called memory allocation! That’s all!

Now to get to the main point of the post… What does Static and Dynamic memory allocation mean then?

(I hope you read the previous post of compilers and interpreters. The knowledge of what compiling means will be used here. Go back and read up if you need to)

Static memory allocation basically means that the memory is allocated during compilation itself. This means that the as soon as the compilation is over, certain space of memory will be fixed for its usage. But in Dynamic memory allocation, the space for the program is given ‘dynamically’, or set during run time. This means that the amount of memory that a program requires will not be set before hand but instead the memory will be allocated step by step depending on the program needs.

The advantage of Dynamic memory (obviously ) is that it ends up using lesser portions of Memory that Static allocation. But it is slower in execution as memory has to be allocated at every step based on the requirements. Check the video below to understand it better.


 

This post didn’t go into the details of the two types, but instead gave you an overview of what the terms mean and how you can go about learning more about it.

Hope you liked it! happy reading!

Comments