Re: Stack vs. Heap Question, Please Help
- From: "Nick Hounsome" <nh002@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 05:30:02 GMT
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1e9625e7d10c6dd98cff1@xxxxxxxxxxxxxxxxxxxxxxx
Nick Hounsome <nh002@xxxxxxxxxxxxxxxxxx> wrote:
<snip>
Re. The stack - the only practical difference between stack and heap at
the
app level is that stack is faster. This is solely because logically it
cannot become fragmented or need GC. I believe that there are or were
micro-controllers that didn't have one.
I don't know - I think that the idea of variables being on the stack or
on the heap (along with the concept of stack frames) is very important
when it comes to understanding threading, and why if two threads are
running the same method at the same time (or even a single thread
running a method recursively) they get separate local variables, but if
they access the same object on the heap, that data is shared.
struct parameters and structs within methods are thread local as
(recursively) are any structs they contain directly. Everything else is
shared. You don't need to use the words stack or heap to explain this.
P.S. It is totally possible to implement a stack in a stackless
architecture - just pass a pointer to the array of arguments and allocate
frames off the heap - of course you then have a "stack" but it is a
different sort of stack and not as efficient for aloocation although the
deallocation efficiency still applies.
.
- Follow-Ups:
- Re: Stack vs. Heap Question, Please Help
- From: Jon Skeet [C# MVP]
- Re: Stack vs. Heap Question, Please Help
- References:
- Stack vs. Heap Question, Please Help
- From: arcticool@xxxxxxxxxxx
- Re: Stack vs. Heap Question, Please Help
- From: Larry Lard
- Re: Stack vs. Heap Question, Please Help
- From: Nick Hounsome
- Re: Stack vs. Heap Question, Please Help
- From: Jon Skeet [C# MVP]
- Stack vs. Heap Question, Please Help
- Prev by Date: Re: Stack vs. Heap Question, Please Help
- Next by Date: Re: Send ctrl-c
- Previous by thread: Re: Stack vs. Heap Question, Please Help
- Next by thread: Re: Stack vs. Heap Question, Please Help
- Index(es):
Relevant Pages
|