473,388 Members | 1,340 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,388 software developers and data experts.

Heap, stack, pile?

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, but what is a pile? Is it just another name for
stack? Doing some reading, I found that value types use stack memory
since the size can be determined at compile time and there's less
overhead with this type of memory. So, I'm thinking this is just
another name for stack. I couldn't find "pile" defined in
webopaedia.com.

Comments appreciated.

Thanks in advance!
Nov 16 '05 #1
4 3323
Robbie,

I've never heard of pile, but I would assume that it means "stack".

With value types, if you declare them in a method, then they are on the
stack. If they are fields in a class, then those are on the heap, because
the instance of the class itself is on the heap.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Robbie" <Ro************@netscape.net> wrote in message
news:17**************************@posting.google.c om...
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, but what is a pile? Is it just another name for
stack? Doing some reading, I found that value types use stack memory
since the size can be determined at compile time and there's less
overhead with this type of memory. So, I'm thinking this is just
another name for stack. I couldn't find "pile" defined in
webopaedia.com.

Comments appreciated.

Thanks in advance!

Nov 16 '05 #2
Robbie <Ro************@netscape.net> wrote:
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, but what is a pile? Is it just another name for
stack? Doing some reading, I found that value types use stack memory
since the size can be determined at compile time and there's less
overhead with this type of memory. So, I'm thinking this is just
another name for stack. I couldn't find "pile" defined in
webopaedia.com.


I haven't heard of "pile" either, to be honest.

Value types reside on the stack if they come from:
o Local variables
o Intermediate expressions (i.e. evaluation on the stack)
o Instance variables where the enclosing value is also on the stack

See http://www.pobox.com/~skeet/csharp/memory.html for more
information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
In other words if the value type is part of the state of a reference type it gets allocated on the managed pile ... sorry heap ... inline with the rest of that object's state.

e.g.

struct Point

{

int x;

int y;

}

class Line

{

Point start;

Point end;

}

The memorry for the Point instances will be allocated on the managed heap when a line instance is created.

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<MP************************@msnews.microsoft.com >

Robbie <Ro************@netscape.net> wrote:
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, but what is a pile? Is it just another name for
stack? Doing some reading, I found that value types use stack memory
since the size can be determined at compile time and there's less
overhead with this type of memory. So, I'm thinking this is just
another name for stack. I couldn't find "pile" defined in
webopaedia.com.


I haven't heard of "pile" either, to be honest.

Value types reside on the stack if they come from:
o Local variables
o Intermediate expressions (i.e. evaluation on the stack)
o Instance variables where the enclosing value is also on the stack

See http://www.pobox.com/~skeet/csharp/memory.html for more
information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004

[microsoft.public.dotnet.languages.csharp]
Nov 16 '05 #4
Richard Blewett [DevelopMentor] <ri******@develop.com> wrote:
In other words if the value type is part of the state of a reference
type it gets allocated on the managed pile ... sorry heap ... inline
with the rest of that object's state.


Exactly. This is why I disagree when people just say "Reference types
are allocated on the heap. Value types are allocated on the stack" and
leave it at that.

I must get round to writing my "definitive guide to reference vs value
types" some time :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Kevin Grigorenko | last post by:
Hello, I couldn't find an obvious answer to this in the FAQ. My basic question, is: Is there any difference in allocating on the heap versus the stack? If heap or stack implementation is not...
17
by: Jonas Rundberg | last post by:
Hi I just started with c++ and I'm a little bit confused where stuff go... Assume we have a class: class test { private: int arr; };
1
by: Geiregat Jonas | last post by:
I'm reading Eric Gunnerson's book. He is talking about the heap and stack, he says you have 2types, value wich are in the stack or inline or reference types wich are in the heap. I don't get...
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...
9
by: shine | last post by:
what is the difference between a heap and a stack?
2
by: Ganesh | last post by:
I am not sure if this question is relevant here. Why is 'heap' (the place where dynamic memory allocation occurs) called so? There is also a data structure called 'heap'. What is the connection? ...
24
by: arcticool | last post by:
I had an interview today and I got destroyed :( The question was why have a stack and a heap? I could answer all the practical stuff like value types live on the stack, enums are on the stack, as...
16
by: sarathy | last post by:
Hi all, I need a few clarifications regarding memory allocaion in C++. I apologize for the lengthy explanation. 1. In C++, Objects are allocated in heap. What does heap refer to? Is it an area...
53
by: fdmfdmfdm | last post by:
This is an interview question and I gave out my answer here, could you please check for me? Q. What are the memory allocation for static variable in a function, an automatic variable and global...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.