473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What is the difference between the Heap and the Stack?

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
2 13729
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve Hill | last post by:
Hi, suppose I have a vector allocated on the heap. Can I use a temporary (stack based vector) and swap to clear it, or is this unsafe. e.g. vector<int> *v; vector<int> tmp; v->swap(tmp); // is...
6
by: Sayan | last post by:
How do I distinguish between a heap pointer and a stack pointer? I want the following to work: template<class T> bool isHeapPtr(T* p1,T* p2);//the function I want to write //... int a = 5;...
2
by: diadia | last post by:
string s = "hello"; const char *p = s.begin(); cout << p << endl; // print hello s = ""; char *p2= s.begin(); cout << p2 << endl; // print hello why?????
3
by: balu | last post by:
Hi Gurus I need a help. Im developing a C++ libaray. I don't whether user creates object in stack/heap. Is there a way to find object location? Balu.N
10
by: Amit | last post by:
char *str1="amit"; char str2="mehta" strcat(str1,str2); It will crash, I feel str1 will be stored in code section. Once memory is allocated, you cannot change or append into this. Please...
2
by: Nick McCamy | last post by:
I have a question related to allocating on the stack. In this program below, are my following assumptions true? - variable a is allocated on the heap since it's static - variable b is...
4
by: Robbie | last post by:
Someone at work asked me this question: Value types--do they hit the heap or the pile? Well, I was a bit dumbfounded, because I never heard of the term "pile". I've heard of heap and stack,...
5
by: bhushanbagul | last post by:
Hi All Please let me know exactly what difference i and g makes in oracle version i.e. when we say oracle 10g or oracle 11i Thanks Bhushan
6
gpraghuram
by: gpraghuram | last post by:
HI All, Someone asked me the following question and i am not able to get an answer for this. In c++ how will you restrict 1)object creation in heap 2)object creation in stack Can anyoine...
0
by: seper254 | last post by:
Hey I am in the middle of Java and I am having trouble drawing heap stack diagrams from code. I have two that I really need help with. First code: public class HEAPSTACK extends ConsoleProgram{...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.