By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

What is the difference between the Heap and the Stack?

P: n/a
Dear ladies and gentlemen,

I don't understand what the difference between the Heap and the Stack
is. Could you please explain the difference between the both for me?

Thank you very much.

Best regards.
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Here it is:
http://whatis.techtarget.com/definit...212239,00.html

Hope this helps,
Arjen

"Ma Xiaoming" <ma**************@sina.com> schreef in bericht
news:%2****************@tk2msftngp13.phx.gbl...
Dear ladies and gentlemen,

I don't understand what the difference between the Heap and the Stack
is. Could you please explain the difference between the both for me?

Thank you very much.

Best regards.

Nov 17 '05 #2

P: n/a
Here is the very good, clear and technical diff..Ma Xiaoming!!

Stack...

1. lives in RAM (random-access memory), but has direct support from the
processor via its stack pointer.

2. stack pointer is moved down to create new memory and moved up to release
that memory.

3. extremely fast and efficient way to allocate storage, second only to
registers.

4. stack is maily used for value types[ Ex : value datatypes in C# ].

5. This portion of the memory is not garbage collectible.

Heap...

1.lives in general-purpose pool of memory (also in the RAM area) where all
objects live.

2. the compiler doesn't need to know how much storage it needs to allocate
from the heap or how long that storage must stay on the heap.

3. Whenever we need to create an object, you simply write the code to create
it using new, and the storage is allocated on the heap

4. to put in simple terms heap memory is used for allocation of memory for
object types (where actual object is created )and only the heap part of the
memory is gargabe collectible (eligible for automatic garbage collection)

hope this will clear...

Mahesh

http://spaces.msn.com/members/cyberiafreak

"Arjen" <bo*****@hotmail.com> wrote in message
news:de**********@news1.zwoll1.ov.home.nl...
Here it is:
http://whatis.techtarget.com/definit...212239,00.html

Hope this helps,
Arjen

"Ma Xiaoming" <ma**************@sina.com> schreef in bericht
news:%2****************@tk2msftngp13.phx.gbl...
Dear ladies and gentlemen,

I don't understand what the difference between the Heap and the Stack
is. Could you please explain the difference between the both for me?

Thank you very much.

Best regards.


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.