delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/12/08:00:13

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <3CB6C8FA.45A31BB7@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: New DJGPP hogs memory (was: I need help)
References: <5 DOT 0 DOT 2 DOT 1 DOT 0 DOT 20020410122845 DOT 00bcbbd8 AT pop DOT mail DOT yahoo DOT com>
<5 DOT 0 DOT 2 DOT 1 DOT 0 DOT 20020410122845 DOT 00bcbbd8 AT pop DOT mail DOT yahoo DOT com> <5 DOT 0 DOT 2 DOT 1 DOT 0 DOT 20020411161942 DOT 00bd1eb0 AT pop DOT mail DOT yahoo DOT com> <2593-Fri12Apr2002115014+0300-eliz AT is DOT elta DOT co DOT il>
Lines: 60
Date: Fri, 12 Apr 2002 11:53:20 GMT
NNTP-Posting-Host: 12.90.174.129
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc04-news.ops.worldnet.att.net 1018612400 12.90.174.129 (Fri, 12 Apr 2002 11:53:20 GMT)
NNTP-Posting-Date: Fri, 12 Apr 2002 11:53:20 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:
> 
> > Date: Thu, 11 Apr 2002 16:25:50 -0500
> > From: =?iso-8859-1?Q?=22Jos=E9_L=2E_S=E1nchez_Garrido=22?=
> >   <jlsgarrido AT yahoo DOT com>
> >
> > typedef struct {
> >      char af[10];
> >      char name[10];
> >
> > } record;
> >
> > record **dt, *d;
> >
> > int main (void) {
> >
> >      int count;
> >
> >      for(count=0; count<200000L; count++){
> >          dt=(record **)realloc(dt, (count+1)*sizeof(record *));
> >          d=dt[count];
> >          d=(record *)calloc(10, sizeof(record));
> >      }
> >      return(0);
> > }
> 
> Can you please tell what memory consumption did you see with each one
> of the two versions of the compiler and the library?
> 
> Also, you don't say what compiler switches did you use to compile and
> link the program.
> 
> Anyway, based on looking into this program, I think the changed
> behavior is due to the new version of malloc in libc.a from DJGPP
> v2.03 (so it has nothing to do with the compiler).  The program uses a
> very bad algorithm--reallocating an array on each iteration,
> increasing its size by 1.  It also allocates the memory in lots of
> very small chunks.  So it doesn't surprise me that you run out of free
> memory.
> 
> My recommendation is to modify the algorithm to do a better
> allocation.  If you cannot do that for some reason, you can find the
> old implementation of malloc in djlsr203.zip, file name
> src/libc/ansi/stdlib/fmalloc.c; link it with your program, and you
> will get the old behavior.

He might also try my suggested new malloc package for DJGPP, which
I have mounted at:

   <http://cbfalconer.home.att.net/download/nmalloc.zip>

which, among other things, goes to some pains to minimize the
realloc work.  I have heard nothing back on it from anyone, either
good or bad.

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!

- Raw text -


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