From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Problem with memory Date: Fri, 13 Mar 1998 20:46:16 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 44 Message-ID: <3509E168.4447@cs.com> References: <6ea7kn$gvv$1 AT kali DOT ziplink DOT net> NNTP-Posting-Host: ppp210.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Jeff Williams wrote: > > Hello, > First off, I have never programmed in protected mode before, so this > question may seem painfully obvious, but I just can't get it. The > problem is, in a game I am making, I need to initialize and use a somewhat > large int array (and it just wont work). The array is supposed to be > 1024x960, but if I initialize an array (after all of the image/sample > loading into memory) larger than 320x200, the program crashes right away. > I don't even have to attempt to manipulate it for it to crash, so I assume > it is a memory problem. I tried doing a malloc loop before and after > loading everything, and for some odd reason, my avail. memory never > decreased or increased (I ran it before loading images, etc, after loading > them, and after initializing the 320x200 array... and it always stayed at > 8mb). I am running Win95, and have 24mb of RAM. Please post the code you use to define and initialize the array; otherwise there's no way we can give you a specific answer. I do have one question - is this array defined automatically, statically, or dynamically? If it is defined automatically, then your problem is that you are running out of stack space. DJGPP programs by default have a 256K stack that cannot be changed at runtime. If you use large automatic arrays or heavy recursion, you may run afoul of this limit and your programs will crash in strange and hard to debug ways. The solutions: - use malloc() to create the array instead of declaring it in array notation. - Increase the stack size of your program (see chapter 15.9 of the DJGPP Frequently Asked Questions list). If this is not your problem, then we must see your code to know what's wrong. -- John M. Aldrich, aka Fighteer I UIN# 7406319 -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS d- s+:- a-->? C++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---) O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++ e(*)>++++ h!() !r !y+() ------END GEEK CODE BLOCK------