Open In App

Is there a limit for the total variables size on the Memory Stack?

Improve
Improve
Like Article
Like
Save
Share
Report

What is Stack?

  • A stack is a conceptual structure made up of a collection of homogeneous elements that operates on the last in first out principle (LIFO). 
  • It is a popular abstract data type with two major operations: push and pop. 
  • Push and pop operations are performed on the topmost element, which is the most recently added item to the stack. 
  • The push operation adds to the stack, whereas the pop operation removes an element from the top position. 
  • The stack concept is used in computer programming and memory organization. 

Is there a limit on the size of the total variables on the stack?

  • Yes, it is constrained by your system’s address space. 
  • It’s also constrained by the amount of stack space allocated by your operating system, which can’t usually be changed after your program starts but can be changed beforehand (either by the launching process or by the properties of the executable). 
  • On some systems, you can even allocate a different amount of stack to each thread you start, though this is only of limited utility.
  • Most compilers also have a limit on how much can be stored in a single stack frame. 
  • It would be a problem if you were writing embedded code or code for use within an operating system kernel. Depending on configuration options, code in the Linux kernel is limited to 64 KB stacks or less.

Related Article:


Last Updated : 03 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads