Mail Archives: djgpp/1996/07/30/03:01:34
> Array is put on the stack. But there is only 256Kb on the stack, so the rest
> of your stack is all over your program. Anyway it is bad practice to use large
> amounts of stack. You should allocate it dynamically if you want big amounts
> of memory.
"Using large amounts of stack" isn't bad practice in general - just on systems
that aren't properly implemented :-) (Hey, I'm allowed to bash what I wrote!)
This is just a big wart on the DPMI 0.9 stuff - DJGPP V1.x under non-DPMI
didn't have it, VMS doesn't have it, unix doesn't have it, etc.
> Array is now static: ie a 1Mb array is made inside your executable, working but
> leading to a bloated >1Mb executable!
The bloat should only happen with C++, and can be avoided with a command line
switch.
> Third choice: malloc: dynamic, no disadvantages.
Big disadvantages: memory leaks, reentrancy of malloc, freeing memory on
exception unwinding (you usually can't, more leaks), bad malloc packages, etc.
For anyone out there who wants dynamic stack expansion, there is a potentially
slow way to do it by starting the stack at 0xffffffff and expanding down in
the same memory block, using a unixy sbrk type algorithm. Morten and I
talked about it a while, but we got busy and didn't write it... Sigh.
- Raw text -