delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/11/08:18:05

From: "Edmund Horner" <ejrh AT paradise DOT net DOT nz>
Newsgroups: comp.os.msdos.djgpp
References: <20000911155441 DOT A493 AT ajax DOT netspace DOT net DOT au>
Subject: Re: Malloc bug in DJGPP V2.03
Lines: 159
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.3018.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300
Organization: Paradise Net
Message-ID: <968648802.631222@shelley.paradise.net.nz>
Cache-Post-Path: shelley.paradise.net.nz!unknown AT 203-96-146-38 DOT tnt2 DOT paradise DOT net DOT nz
X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/)
Date: Mon, 11 Sep 2000 17:08:43 +1200
NNTP-Posting-Host: 203.96.152.26
X-Complaints-To: newsadmin AT xtra DOT co DOT nz
X-Trace: news.xtra.co.nz 968648803 203.96.152.26 (Mon, 11 Sep 2000 17:06:43 NZST)
NNTP-Posting-Date: Mon, 11 Sep 2000 17:06:43 NZST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'm afraid that I think you need to really worry about doing lots of
malloc'ing: it gets expensive if you use lots of small blocks.

Perhaps you should try to malloc in bigger chunks at a time.  This could
probably be achived by adding another layer to the malloc implementation,
that allocates space for (say) 1024 objects at a time.

On the other hand, it might well be a bug.  Try one of the other malloc
implementations to be found at http://www.delorie.com/djgpp/malloc/

"Andrew Apted" <ajapted AT netspace DOT net DOT au> wrote in message
news:20000911155441 DOT A493 AT ajax DOT netspace DOT net DOT au...
> I'm experiencing a problem with my DJGPP program (glBSP, a nodes
> builder for DOOM) where it runs out of memory under DOS, even though
> there should be plenty left.  I've memory-profiled the code (under
> Linux), and the most it ever uses (not including overheads) is 9 MB,
> yet my machine has 64 MB RAM.  This is with DJGPP V2.03.
>
> Below is a test program which can reproduce the problem, which is
> similiar to my program (it allocates lots of small objects, around 32
> bytes each).  The most it ever uses is 9 MB (excluding overheads in
> malloc), yet it always fails here with out of memory before reaching
> the end.  The furthest it gets is POS 66, when CWSDPMI's internal heap
> parameter is [128], and POS 131 when it is [1024].
>
> Also below is the output of go32-v2 etc...
>
> This is clearly a bug in DJGPP's malloc functions, right ?
>
> Cheers,
> __
> \/   Andrew Apted  <ajapted AT users DOT sourceforge DOT net>
>
>
> ========================================================================
>
> /*
>  * TESTMEM
>  */
> #include <stdio.h>
> #include <stdlib.h>
>
> typedef struct blob_s
> {
>   struct blob_s *next;
>   int data[7];
> }
> blob_t;
>
> int main(void)
> {
>   int i;
>   int actual = 0;
>
>   blob_t ** array[16] = { NULL, };
>
>   for (i=0; i < 256000; i++)
>   {
>     int hi = i % 16;  // breadth first
>     int lo = i / 16;
>
>     if ((i % 1000) == 0)
>       fprintf(stderr, "POS: %d/%d  ACTUAL: %d\n", i / 1000, 255, actual);
>
>     array[hi] = realloc(array[hi], (lo + 1) * sizeof(blob_t *));
>     actual += sizeof(blob_t *);
>
>     if (array[hi] == NULL)
>     {
>       fprintf(stderr, "OUT OF MEMORY ! (realloc)\n");
>       return 1;
>     }
>
>     array[hi][lo] = calloc(1, sizeof(blob_t));
>     actual += sizeof(blob_t);
>
>     if (array[hi][lo] == NULL)
>     {
>       fprintf(stderr, "OUT OF MEMORY ! (calloc)\n");
>       return 1;
>     }
>
>     (array[hi][lo])->data[0] = hi;
>     (array[hi][lo])->data[1] = lo;
>   }
>
>   return 0;
> }
>
>
> ========================================================================
>
> output of go32-v2:
>
> go32/v2 version 2.0 built Dec 24 1999 17:46:57
> Usage: go32 coff-image [args]
> Rename this to go32.exe only if you need a go32 that can run v2 binaries
as
>  well as v1 binaries (old makefiles).  Put ahead of the old go32 in your
PATH
>  but do not delete your old go32 - leave it in the PATH after this one.
> Set GO32_V2_DEBUG=y in the environment to get verbose output.
>
> DPMI memory available: 64455 Kb
> DPMI swap space available: 13617 Kb
>
> output of set:
>
> COMSPEC=C:\COMMAND.COM
>
PATH=C:\DJGPP\BIN;C:\VIM-5.3;C:\LYNX\LYNX;C:\;C:\DOS;C:\WINDOWS;C:\AMOUSE;C:
\UTILS;C:\TC;C:\XTGOLD;C:\ACRODOS
> TEMP=C:\TEMP
> SCSI_DRIVER=C:\IOMEGA
> SCSI_UTILITY=C:\IOMEGA
> DOOMWADDIR=C:\GAMES\DOOM2
> BLASTER=A220 I7 D1 H5 P330 T6
> DJGPP=C:\DJGPP\DJGPP.ENV
> PROMPT=$p$g
> DA=0
>
> config.sys:
>
> DOS=HIGH
> DOS=UMB
> FILES=40
> FCBS=40,0
> BUFFERS=40
> STACKS=9,256
> LASTDRIVE=Z
> DEVICE=C:\WINDOWS\HIMEM.SYS
> DEVICEHIGH=C:\DOS\ANSI.SYS
> DEVICEHIGH=C:\WINDOWS\IFSHLP.SYS
> DEVICEHIGH=C:\SBCD\SBIDE.SYS /D:SBPCD /V /P:170,15,376
> SHELL=C:COMMAND.COM /E:8192 /P
>
> autoexec.bat:
>
> @ECHO OFF
>
PATH=C:\DJGPP\BIN;C:\VIM-5.3;C:\LYNX\LYNX;C:\;C:\DOS;C:\WINDOWS;C:\AMOUSE;C:
\UTILS;C:\TC;C:\XTGOLD;C:\ACRODOS
> SET TEMP=C:\TEMP
> SET SCSI_DRIVER=C:\IOMEGA
> SET SCSI_UTILITY=C:\IOMEGA
> SET DOOMWADDIR=C:\GAMES\DOOM2
> SET BLASTER=A220 I7 D1 H5 P330 T6
> SET DJGPP=C:\DJGPP\DJGPP.ENV
> PROMPT $p$g
> C:\CDROMDRV\MSCDEX /D:SBPCD /L:R /M:8 /V
> C:\DOS\SMARTDRV /X 512 512
> DOSKEY /INSERT
> MODE CON LINES=50
> AMOUSE /R1 /C
> ECHO.
> MENU
>


- Raw text -


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