delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/06/00:32:40

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How big can I make my array?
Date: Sat, 06 Jun 1998 00:23:25 -0400
Organization: Two pounds of chaos and a pinch of salt.
Lines: 33
Message-ID: <3578C43D.F4DDB90@cs.com>
References: <MPG DOT fe223cb1cc75732989717 AT news DOT virgin DOT net>
NNTP-Posting-Host: ppp127.cs.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Andrew R. Gillett wrote:
> 
>     struct pixel_struct pixel[AREA_WIDTH][AREA_HEIGHT];
> 
> [rest of class and program...]
> 
> AREA_WIDTH = 640, AREA_HEIGHT = 480. I also get this error with 256x200,
> the lowest mode Allegro can do.
> 
> I read a bit in the FAQ which said that CWSDPMI couldn't handle it if
> there were a lot of small memory allocations needed. I don't know if this
> is what is causing the problem here. Memory allocation is not my
> speciality.

[Why do these kinds of problems always seem to occur in bunches?]

Your problem is stack overflow.  If you declare a local object of that
class, you're allocating all of the memory for the array from the
stack.  Since the default runtime stack for DJGPP programs is 256K,
you're overflowing it and your program will therefore crash most
spectacularly.

There are two solutions:  you can read chapter 15.9 of the DJGPP FAQ to
learn how to increase the stack size of your programs, or you can take
the better route and create your object statically or dynamically.

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "A generation which ignores history  |
|       aka Fighteer I       | has no past--and no future."         |
|   mailto:fighteer AT cs DOT com   |                                      |
| http://www.cs.com/fighteer |                - Lazarus Long        |
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019