Mail Archives: djgpp/1998/04/01/20:01:06
Aquinas wrote:
>
> So in a DPMI/Protected mode environment like DJGPP, why can't you have a
> big-ass array like int x[1000000]? Is there a good explanation of this
> somewhere? Any help would be much appreciated.
Of course you can have an array that big (assuming you have at least 4
MB of physical+virtual memory available). The problem is that automatic
arrays, such as the one in your code, are allocated on the stack, which
is only 256K by default in DJGPP programs. Trying to grab more than
this will cause your programs to behave very strangely, if not crash
outright.
There are three solutions. The first is to declare the array static
instead of automatic; i.e., with the 'static' keyword or globally. The
second is to dynamically allocate it, via malloc() and family. The
third is to manually increase the size of the stack. This issue is
discussed in detail in chapter 15.9 of the DJGPP Frequently Asked
Questions list, which I suggest you read.
hth
--
---------------------------------------------------------------------
| John M. Aldrich | "Always listen to experts. They'll |
| aka Fighteer I | tell you what can't be done, and why.|
| mailto:fighteer AT cs DOT com | Then do it." |
| http://www.cs.com/fighteer/| - Lazarus Long |
---------------------------------------------------------------------
- Raw text -