The memory eater strikes back (2nd attempt to get attention)

Knobi der Rechnerschrat XBR2D96D at DDATHD21.BITNET
Sat Oct 21 22:34:15 AEST 1989


Hello,

  I've posted this one month ago, but I think I've never seen an answer to
the following problem:

  To get best performance in memory allocation I want to use the malloc(3X)
routines by using '-lmalloc' at link time. Now it seems that there is something
wrong with it, because 'free' doesn't seem to work when using '-lmalloc'. The
code fragment attached to this mail does allocation/deallocation of some
ammount of memory in a endless loop. Using the libraries

              -lgl_s -lbsd -lfastm -lm -lc_s            #(make mem)

everything is fine. Using instead the libraries

              -lgl_s -lmalloc -lbsd -lfastm -lm -lc_s   #(make meml)

the process' memory size is increasing and on a 8MB GT the system is after
about 50 steps saturated with really heavy paging. What I really would
like to know is:

a) Is it my fault (using wrong library order?)?
b) Is it a bug?
   - known?
   - fixed when?
c) Is there really a performance gain when using -lmalloc (supposed it
   works properly)?

Any comments are welcome and appreciated.


Regards
Martin Knoblauch

TH-Darmstadt
Physical Chemistry 1
Petersenstrasse 20
D-6100 Darmstadt, FRG

BITNET: <XBR2D96D at DDATHD21>

-------------------------makefile-----------------------------------------
#
#  make - directives
#
CFLAGS = -g  -I/usr/include/bsd
#
# Library Selection
#
LIBRL = -lgl_s -lmalloc -lbsd -lfastm -lm -lc_s
LIBR = -lgl_s -lbsd -lfastm -lm -lc_s
#
#
#
mem:    mem.c
        cc mem.c $(CFLAGS) -o mem $(LIBR)
#
meml:   mem.c
        cc mem.c $(CFLAGS) -o meml $(LIBRL)
#
-------------------------mem.c--------------------------------------------
/*
**      MOLCAD  Version 4.1
**
**      COPYRIGHT AND ALL OTHER RIGHTS RESERVED
**
**      Contact:
**
**       Prof. Dr. J. Brickmann
**       c/o TH - Darmstadt
**       Dept. for Physical Chemistry
**       Petersenstr. 20
**       D-6100 Darmstadt, FRG
**
**       BITNET  : <XBR2D96D at DDATHD21.BITNET>
**
**
**       file    :  mem.c
**       author  :  Martin Knoblauch + Michael Teschner
**       date    :
**       purpose :  memory allocation test
**       comment :
**
**
**
**
*/

#include <stdio.h>
#include <malloc.h>

int acount,dcount;

struct Dot { struct Dot *next;
             float arr[4];
            };

extern struct Dot *mk_Newdot();

main()
{
struct Dot *first,*dot;
int i,j,count;

first = NULL;

for(j=0;j<1000;j++){

    mk_Deldots(first);
    dot = first = NULL;

    count = 0;
    for(i=0;i<5000;i++){
      dot = mk_Newdot(dot);
       count++;
      if( first == NULL )  first = dot;
      }

 printf(" loop %d count %d \n",j,count);
 }

} /* end main */



struct Dot *mk_Newdot(prev)
struct Dot *prev;
{
struct Dot *help;

if ((help = (struct Dot *)malloc(sizeof(struct Dot))) == NULL)
        return(NULL);

if (prev != NULL) prev->next = help;
help->next = NULL;
return(help);
}


mk_Deldots(start)
struct Dot *start;
{
struct Dot *help;

while (start != NULL) {
  help = start->next;
  free(start);
  start = help;
  }
}
--------------------------------------------------------------------------



More information about the Comp.sys.sgi mailing list