Mail Archives: djgpp/1999/02/28/10:31:06
Matteo Sasso wrote:
>
> That's a bug I discovered writing a program a year ago.
> I was trying to make a game, and I malloc'd two "screens of memory" (I
> used a 800x600x32bit resolution, so one screen of memory is 1875Kb of
> memory). I used it as a virtual screen, since the one I could use with
> Allegro was too little for my purposes. Everything was fine. Then I
> increased the memory to four end then eight screens of memory (15Mb in
> total). Since I had 32 Mb of RAM, I thought that it could work, but my
> program crashed orribly! I asked the author of DJGPP but he couldn't
> give me an answer.
> It looks like DJGPP cannot handle VERY HUGE quantity of memory!
I don't think 15 megs is a huge amount of memory, but...
this retarded program I wrote in 5 seconds (heavily using cut'n'paste)
allocates what should be about 20 megs of memory. I only have 16 (unless
someone secretly came into my house and added more memory to my PC)
it then 'writes' some text at different places in the array. it ends by
printing that text. the program works fine on my pc.
also note that the second 'write' is very close to the end of the array,
around 20 megs, so far out of my physical memory.
second note: djgpp is limited by the amound of memory the DPMI server
can handle. In CWSDPMI it's 256 megs, I think. Under windows, I dunno,
but it's not 15 megs.
unsigned char *ptr;
void main(void)
{
ptr=malloc(20000000); //about 20 megs
ptr[1]='h';ptr[2]='e';ptr[3]='l';ptr[4]='l';ptr[5]='o';
ptr[19111111]='t';ptr[19111112]='h';ptr[19111113]='e';ptr[19111114]='r';
ptr[19111115]='e';
printf("\n %c%c%c%c%c %c%c%c%c%c",ptr[1],ptr[2],ptr[3],ptr[4],ptr[5]\
,ptr[19111111],ptr[19111112],ptr[19111113],ptr[19111114],ptr[19111115]);
free(ptr);
}
- Raw text -