UStudy aims to provide Educational Content for Polytechnic College students based on the latest K Scheme syllabus of Tamil Nadu.
The main advantage of using dynamic memory allocation is preventing the wastage of memory. This is because when we use static memory allocation, a lot of memory is wasted because all the memory allocated cannot be utilised. Thus dynamic memory allocation helps us to allocate memory as and when required and thus saves memory.
In static memory allocation, if we allocate 1000 memory locations as int name; While running the program only half of this may be used. The rest is unused and idle. It is a wastage of memory.
If we want to change the size of the array in the program, it is possible by reediting the program. It is a time consuming process.
In dynamic memory allocation the above two problems won't occur because, the memory space for variables is allocated only during execution.