+ 5

what is the difference between heap and stack?

11th Jul 2016, 6:35 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
6 odpowiedzi
+ 3
when you use "new" keyword to allocate memory it would be done in heap.. when you use any data types to allocate memory they would be in stack..
13th Jul 2016, 8:14 PM
kiran
+ 2
@kiran how do they function?
13th Jul 2016, 7:57 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 1
A heap is a data structure and A stack is abstract data types(mathemetical model for a data structure).
11th Jul 2016, 10:44 PM
sakje coookie
sakje coookie - avatar
+ 1
whenever you want to store data dynamically and free the data you have to allocate memory on runtime...when you does..this data stores in heap memory area. whatever you declare the variables while coding those would store in stack area and are automatically deallocated.
13th Jul 2016, 7:48 PM
kiran
+ 1
@kiran only a difference in name??
13th Jul 2016, 7:51 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 1
@Maths : in the systems logical memory area also different for heap and stack
13th Jul 2016, 7:54 PM
kiran