Mail Archives: djgpp/1998/09/25/04:00:56
From: | bitland AT aol DOT com (Bitland)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | malloc/new once again
|
Lines: | 37
|
NNTP-Posting-Host: | ladder02.news.aol.com
|
Date: | 25 Sep 1998 07:59:23 GMT
|
Organization: | AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com
|
Message-ID: | <19980925035923.00799.00001778@ng85.aol.com>
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hello !
I got version 2.8.1 and still have malloc-problems. Allocating memory in an
absolutely simple program and freeing it in the next moment, displaying the
memory with __dpmi_get_free_memory_information(&dfmi); gives confusing
memory values and then the memory slowly gets low.
Here's the main loop (simulating making allegro bitmaps), with MAXSIZE 1024,
CDEPTH 32 and MAPS so, that you cannot allocate more than you have, but be sure
to get closely to the limit, then the effect comes faster.
do
{
for (i=0;i<MAPS;i++)
{
hm[i] = malloc((CDEPTH>>3)*(random()%MAXSIZE * (random()%MAXSIZE)));
if (!hm[i])
textout(screen,font,"there it is !",200,20,COLWHITE); /* via allegro
*/
}
checkmem("allocated");
for (i=0;i<MAPS;i++)
if (hm[i])
free(hm[i]);
checkmem("freed ");
} while (!keypressed());
After this, you SOMETIMES cannot get a large memory block !
And 'there it is' shouldn't appear at all, what if allocated with 'new' without
a newhandler ? The program crashes...
Any idea without a do-it-yourself-memory-manager ?
Please mail me
Andy Kluge BITLAND AT AOL DOT COM
- Raw text -