www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/01/16:45:34

Newsgroups: comp.os.msdos.djgpp
From: aquinas AT pacificcoast DOT net (Aquinas)
Subject: Help me understand memory limits!!
Keywords: memory newbie
Date: Tue, 31 Mar 1998 07:50:30 GMT
NNTP-Posting-Host: sd70-223.pacificcoast.net
Message-ID: <3520a3d4.0@news.pacificcoast.net>
Lines: 47
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Okay, I'm new to this C/DJGPP/Programming stuff so bear with me....

Can someone direct me to a good explanation of memory allocation limits, and 
how to allocate large amounts of memory in DJGPP (presumably this involves 
DPMI servers and such).  What I'm wondering right now is....

The following program crashes due to a stack dump of some sort (I'm somewhat 
shaky on what this means)...

int main() {

double x[10000][100];
int count;
int count2;
for (count=1; count < 10000; count++)
for (count2=1; count2 < 100; count2++)
{
x[count][count2] = count2*count;
printf("%d\n",x[count][count2]);
}
return 0;
}

Obviously all this program does is try to crash my making too big an array.  
It worked okay when modified to:

int main() {

double x[10][100];
int count;
int count2;
for (count=1; count < 10; count++)
for (count2=1; count2 < 100; count2++)
{
x[count][count2] = count2*count;
printf("%d\n",x[count][count2]);
}
return 0;
}

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.  

                                                Thanks in advance,
                                                Joe Aquinas
                                                aquinas AT pacificcoast DOT net

- Raw text -


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