STATIC MEMORY ALLOCATION
In static memory allocation, the
decision concerning the amount of memory to be allocated is made at compile
time. However, memory will be allocated at run time only.
Its limitations are, programmers
are forced to predict the amount of data program will utilize. During run time
if more memory is required, static memory allocation cannot fulfill the need.
STATIC MEMORY DEALLOCATION
The Compiler writes instructions
in the executable file to deallocate the memory previously allocated for
variables, when it encounters the end of the function or end of the file. When
the executable file is run, all the instructions contained in it including the
ones to deallocate memory are also executed. Thus memory allocated previously
will be deallocated.
Thus memory is deleted
automatically when the end of a function or file is reached. This is called
Static memory deallocation. However memory will be deallocated only at run
time.
Its limitations are, once a
certain memory block is no longer of any use to the program, memory allocated
to it cannot be released immediately. The memory will continue to be held up
until the end of the block in which the variable was created.
No comments:
Post a Comment