Re: exception access violation
- From: "Alex R. Mosteo" <devnull@xxxxxxxxxxxxxx>
- Date: Wed, 15 Nov 2006 14:32:11 +0100
Georg Bauhaus wrote:
Why is using the heap + controlled for larger data structures
more portable than using the stack? I know that GNAT needs to
be talked into providing sufficient space on the stack.
You might be that running into this kind of stack trouble only
when you port from another compiler to GNAT?
I have no experiences out of GNAT, that be said first.
In past times, I had to deal with implicit limits in Linux/ld (I seem to
remember it was 2MB. This has changed with kernels and is no longer an
issue). Because of this, porting from Windows to Linux was somewhat painful
because problems not arising in Windows did arise in Linux (even using the
usual linker stack options, so I had to dig for even more obscure
switches). Other languages don't exploit so much the stack, so it is more
difficult to find experiences in the area from other developers.
Other point that may be relevant: by default, gnat doesn't release memory
historically claimed by stacks, contrarily to heap-allocated one. Couple
this with lots of tasks or recursivity and quickly memory can start to be
an issue. (I'm not sure if this is linux 2.6 default behavior or gnat
management of secondary stacks, couldn't locate it in the docs).
Finally is the trap I always fall for: "This is small enough to be in the
stack". And then it grows, and then it starts to be a problem, or some
recursive algorithm can't recurse enough, and you end changing it or having
humongous stacks or reworking algorithms.
Of course, in realtime environments you'll prefer to know your memory needs
from the start.
Should the decision whether some object lives on the heap or on
the stack be based on compilers' support for dynamically sized
local data structures?
As long as compilers are not perfect, I suppose it is at least an extra
factor to consider. Also, I'd not limit it only to dynamically sized data.
I've been bitten several times by stack-related problems when using GNAT,
that's all I wanted to transmit (hence the 'in my experience' remark). If
you don't have desires to learn about system internals, GNAT
primary/secondary stacks and so... use the heap, luke ;)
It is worrysome that I'm saying all this, because I find much more
comfortable using the stack than any heap management.
.
- References:
- exception access violation
- From: Jade
- Re: exception access violation
- From: Alex R. Mosteo
- Re: exception access violation
- From: Jade
- Re: exception access violation
- From: Alex R. Mosteo
- Re: exception access violation
- From: Georg Bauhaus
- exception access violation
- Prev by Date: generation of map files
- Next by Date: Re: gnade error
- Previous by thread: Re: exception access violation
- Next by thread: Re: exception access violation
- Index(es):
Relevant Pages
|
|