Describe the issues in a programming language design that affects storage management?


There are various issues in programming language design that affect the utilization of storage by a running program. There are several elements to which storage must be allocated to execute the object program. Storage space is majorly required for object programs and user-defined data structures, variables, and constants. There is also a need for storage space for procedure linkage information, temporaries required for expression evaluation, and parameter passing.

There are the different ways in which various programming languages arrange space for object program are −

  • Static storage allocation− It is the simplest allocation scheme in which allocation of data objects is done at compile time because the size of every data item can be determined by the compiler. The storage space for all programs and data can be allocated at compile time, statically if the size of every data item can be determined by the compiler and if recursive procedure calls are not permitted. This scheme is easy to implement and requires no runtime support.

  • Dynamic storage allocation− If a programming language permits either recursive procedures or data structures whose size is adjustable, then dynamic storage allocation is necessary.

There are two types of dynamic storage allocation which are as follows −

  • Stack allocation− It is useful for handling recursive procedures. As each procedure is called, it places its data on top of a stack, and when the procedure returns, it pops its data off the stack. Some sort of stack is used at run time.

Advantages

  • It supports recursion.
  • It creates a data structure for the data item dynamically.

Disadvantages

  • Memory Addressing can be done using pointers & index Registers. So, the type of allocation is slower than static allocation.
  • Heap allocation− It is useful for implementing data whose size varies as the program is running. It involves taking a large block of memory and dividing it into variable-length blocks, some used for data and some free. When a piece of data is created, it can find a free block of memory. When data is no longer needed, its block becomes free.

There are two methods used for Heap management are as follows −

Garbage Collection Method

When the all-access path to an object is destroyed, but data object continues to exist, such types of objects are said to be garbage. Garbage collection is a technique that is used to reuse that object space.

Reference Counter

By reference counter, an attempt is made to reclaim each element of heap storage immediately after it can no longer be accessed.

Ginni
Ginni

e

Updated on: 08-Nov-2021

463 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements