X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: damonhastings AT yahoo DOT com (Damon Hastings) Newsgroups: comp.os.msdos.djgpp Subject: Help! Can't allocate 512KB static array?? Date: 6 Feb 2002 01:35:55 -0800 Organization: http://groups.google.com/ Lines: 28 Message-ID: <76c7896d.0202060135.4fbf94e9@posting.google.com> NNTP-Posting-Host: 66.81.77.183 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1012988155 26450 127.0.0.1 (6 Feb 2002 09:35:55 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: 6 Feb 2002 09:35:55 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Can anyone tell me why the following program fails under djgpp on my machine? main() { char foo[524273]; for (int i=0; i<524273; i++) foo[i] = 0; } Pretty simple, right? Well, it sometimes throws a SIGSEGV fault, sometimes locks up, sometimes provokes Windows to pop up an application termination dialog, and sometimes spontaneously reboots the computer. Similar results under DOS. It works for an array size of 524272 or if I use malloc() or new instead of a static array. I get the same result if I use int[131069] or if I break it into several smaller arrays. So I'm guessing this all means djgpp has a 512K stack limit, right? How do I change this limit? Or do I have no choice but to use the heap? (And it would be *nice* if I got a compile-time error instead of spontaneous reboots, if any powers-that-be are reading this...) Thanks, Damon Hastings P.S. I'm running the latest djgpp suite (with gcc303), I've got 512MB physical RAM, and go32-v2 reports 430MB DPMI memory available. I've tried it under Win98 and just plain DOS.