I think the main reason is because the stack is a stack. It is LIFO structure, and very tightly controlled by the CPU. It's for local variables only; when, say, a function goes out of scope, its variables are popped off and removed.
It is also designed to (hopefully) remain entirely in CPU cache, so the variables can be accessed very quickly. It's supposed to be efficient, with little risk of memory fragmentation.
Heap memory, on the other hand, it vastly larger. It is better suited for random access, and won't necessarily stay in the cache.
Thus, the stack should not be larger. It is best suited for temporary variables that will be used and destroyed, especially those that will be accessed frequently. The heap is for everything else. Large data structures should always, always, always be in heap space, not stack space! That's just how the two memory spaces were designed.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think the main reason is because the stack is a stack. It is LIFO structure, and very tightly controlled by the CPU. It's for local variables only; when, say, a function goes out of scope, its variables are popped off and removed.
It is also designed to (hopefully) remain entirely in CPU cache, so the variables can be accessed very quickly. It's supposed to be efficient, with little risk of memory fragmentation.
Heap memory, on the other hand, it vastly larger. It is better suited for random access, and won't necessarily stay in the cache.
Thus, the stack should not be larger. It is best suited for temporary variables that will be used and destroyed, especially those that will be accessed frequently. The heap is for everything else. Large data structures should always, always, always be in heap space, not stack space! That's just how the two memory spaces were designed.