[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.9 I got an exception when accessing an `array [1 .. 4000000] of Byte'.

Per default, the maximum stack size of a DJGPP application is 256K. If you need more, you have to adjust it with the stubedit program, i.e.:

 
stubedit your_app.exe minstack=5000K

Another way is to add the following code to your program to define a minimum stack size (here: 2 MB). This value will be honored even if a user sets a lower value by using stubedit, so this method might be a little safer.

Note: The syntax given here is valid for GPC releases of May 2000 and newer.

 
{$ifdef DJGPP}
const
  MinStackSize: Cardinal = $200000; asmname '_stklen';
{$endif}

Still, it might be a good idea to use pointers for large structures, and allocate the memory at runtime.

DJGPP has to allocate the stack in physical memory at program startup, so one might have to be careful with too large stack limits. Most other systems allocate stack pages on demand, so the only reason to set a limit at all might be to prevent a runaway recursion from eating up all memory ...

On Unix-like systems, you can set a resource limit, but you don't do it in normal programs, but rather in the shell settings (bash: `ulimit'; csh: `limit'; syscall: `setrlimit'(2)).



This document was generated by Frank Heckenbach on May, 10 2002 using texi2html