From: j DOT aldrich6 AT genie DOT com Message-Id: <199604260152.AA095763564@relay1.geis.com> Date: Fri, 26 Apr 96 01:55:00 UTC 0000 To: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Subject: Re: problem with DJGPP and arr Reply to message 8372573 from GAGHON AT NEVADA on 04/23/96 11:03PM >Ok I am having a problem with DJGPP and large arrays. All my arrays do >not exceed 2megs of RAM (combined). There's your problem right there. Something similarly evil happened to me not long ago, and it was because DJGPP's default stack size is 256KB, and your arrays are being allocated WAY beyond the bottom of that stack. Remember your basic memory organization: ---Top--- /\ | --Heap--- (grows upwards) --Stack-- (grows downwards) | \/ --Data--- (static storage) | --Code--- (static storage) | -Bottom- (OS & other low-level stuff) If you use more stack space than is allocated, your automatic variables begin overwriting first your static storage,followed by your code, followed by low-level memory. When your program tries to write into this space, the DPMI host generates a segmentation violation (or a page fault - I'm not sure which). BTW, the FAQ's solution tothe problem is wrong (unless the FAQ has been updated?). You can certainly stubedit your executable with no problem, but to increase the stack within your program, you have to put the following line in your main program file: unsigned int _stklen = ; Where is the amount of stack you want to allocate. Do NOT declare it extern, because you can't declare extern and initialize at the same time. However, if you are really using as much storage space as you seem to be, you'd be much better off simply declaring the variables as static, so they get allocated in your static data space. Hope this helps John