What is stack memory and heap memory? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is stack memory and heap memory?

What is stack memory and heap memory? Why are they both used? What new is for?

12th Nov 2016, 6:25 PM
Parker Queen
Parker Queen - avatar
2 Answers
0
stack: it is for functions. each function will be loaded in stack. Heap: it is for variables in each function. all the variables for that particular function will be loaded in heap. when your recursive function does maximum calls for self, you'll get a stack overflow. when your function uses a lot of variables and when they try to store the values but no space, you'll get out of memory error.
12th Nov 2016, 9:16 PM
Nagendra Prajwal
Nagendra Prajwal - avatar
0
owh great, thanks @nagendraprajawal
13th Nov 2016, 1:10 AM
Parker Queen
Parker Queen - avatar