Path: utzoo!attcan!uunet!cs.utexas.edu!uwm.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!DDATHD21.BITNET!XBR2D96D From: XBR2D96D@DDATHD21.BITNET (Knobi der Rechnerschrat) Newsgroups: comp.sys.sgi Subject: The memory eater strikes back (2nd attempt to get attention) Message-ID: <8910210901.aa24434@SMOKE.BRL.MIL> Date: 21 Oct 89 12:34:15 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 151 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: -------------------------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 : ** ** ** file : mem.c ** author : Martin Knoblauch + Michael Teschner ** date : ** purpose : memory allocation test ** comment : ** ** ** ** */ #include #include 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; } } --------------------------------------------------------------------------