Question

In: Computer Science

What are the major drawbacks of static allocation? How does a hybrid allocation scheme consisting of...

What are the major drawbacks of static allocation? How does a hybrid allocation scheme consisting of static allocation, stack-based allocation, and heap based allocation solve the problem

Solutions

Expert Solution

STATIC ALLOCATION

In static memory allocation, the memory required for a program to execute is known beforehand. A fixed amount of memory is allocated to the process due to which a process cannot grow in size even it if needs to. If the exact memory required for execution is not known then the memory needed must be guessed which leads to wastage of memory. As it does not need memory allocation while running, the execution is pretty fast.

  • Memory required is known before execution.
  • Faster execution of a program
  • Leads to wastage of memory

HYBRID ALLOCATION

To overcome the above-mentioned problem, a hybrid scheme is used to execute programs. This consists of static allocation, stack-based allocation and heap allocation. Static allocation is done for class-level variables which are shared across the whole program. For example, in Java static variables are shared for all the objects and not created separately for each object.

Stack-based allocation is used for allocating memory to currently executing method's variable. As soon as a method finishes executing, all the respective variable is deleted and the stack frame is popped off the stack. This is done to save memory and engage it only when necessary. Each method/function gets a new stack frame. It must be noted that each Thread has a whole stack of its own.

  • Formal parameters are stored on the stack
  • The stack frame is created for each method separately
  • Only one stack frame is active at a time
  • Each Thread has a stack of its own.

Heap-based allocation: It is implemented along with stack-based allocation in most of the languages. The idea is that an object is generally very large and cannot be accommodated on the stack and even if it could, it would be very difficult to create and delete such large objects frequently, so this object is stored on heap memory, now what is heap memory? In a layman's language, heap memory is simply the free space available on the RAM. All the objects are created on the heap-memory and referenced from a variable which is stored on the stack. The reference variable holds merely the address of the heap-memory where the object is stored. To manage heap-memory, many algorithms are applied. Java uses MARK AND SWEEP to delete all the dead objects from the heap which cannot be accessed from the stack.

  • Heap memory is used to store large objects
  • It is accessed by a variable which is present on the stack
  • Heap memory management is done separately

Related Solutions

how does a paid for performance scheme o facilitate a more efficient allocation of resources (effort)...
how does a paid for performance scheme o facilitate a more efficient allocation of resources (effort) on the part of the employees (agents) within the firm? I’m not necessarily talking about the agency problems here … just how P4P could be better than some mandated policies and procedures imposed by a manager.
10. Give major drawbacks of outsourcing your IT infrastructure? 11. What does Eucalyptus stand for? 12....
10. Give major drawbacks of outsourcing your IT infrastructure? 11. What does Eucalyptus stand for? 12. Name the five components of Eucalyptus. 13. Give two ways/levels of accessing the Eucalyptus? 14. What are the benefits of Eucalyptus?
what is a hybrid system and how does that combine the best attributes of proprietary and...
what is a hybrid system and how does that combine the best attributes of proprietary and contract security?
France's hybrid system of government. How does the hybrid system solve some of the problems France...
France's hybrid system of government. How does the hybrid system solve some of the problems France experienced with a parliamentary system?  
What does the static keyword mean?
What does the static keyword mean?
- 4. What is cultural relativism in ethics? Explain this idea, and its major drawbacks.
- 4. What is cultural relativism in ethics? Explain this idea, and its major drawbacks.
Explain what is qualitative research and why it might be useful to marketers. What are its major drawbacks?
Explain what is qualitative research and why it might be useful to marketers. What are its major drawbacks?  
Efficiency and how to determine an efficient allocation using demand and supply curves; differences between static...
Efficiency and how to determine an efficient allocation using demand and supply curves; differences between static and intertemporal efficiency.
1. In your opinion, what are two major advantages, and two drawbacks, of having Millenials in...
1. In your opinion, what are two major advantages, and two drawbacks, of having Millenials in the workplace? Explain.
What are the major developments in Novel hybrid inorganic - organic polymer systems in the last...
What are the major developments in Novel hybrid inorganic - organic polymer systems in the last 10 years?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT