Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What is the difference between stack and heap?

Status
Not open for further replies.

sivamit

Full Member level 4
Full Member level 4
Joined
Dec 1, 2005
Messages
201
Helped
20
Reputation
40
Reaction score
14
Trophy points
1,298
Activity points
2,651
Is heap a RAM segment?
What is the difference b/w stack and heap?
Please explain.
How it gets initialised to 0 when a variable is declared as static or extern variable why not stack?
 

Re: Heap/Stack

The stack is used for passing and returning arguments to functions and for local function variables. The function creates a stack frame for this, which helps it use the stack as fast local memory for storing tempary variables and then restore the stack when it is done. The stack grows up or down as functions call functions etc.
The stack has a defined size allacated by you or the compiler/linker.
An area of memory is set aside for storing global variables, arrays, constants etc.
This is done by the linker. If you have a linker script, you can edit this.
The heap is the free memory left. It usually grows in the opposite direction to the stack so they meet in the middle. If you dynamicaly allocate memory using malloc you are using the heap.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top