Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!csd4.milw.wisc.edu!leah!rds95 From: rds95@leah.Albany.Edu (Robert Seals) Newsgroups: comp.unix.questions Subject: malloc(3) vs. malloc(3x) Keywords: ultrix, 4.3-tahoe Message-ID: <1418@leah.Albany.Edu> Date: 6 Jan 89 16:32:36 GMT Organization: The University at Albany, Computer Services Center Lines: 66 How much can a single malloc get? And why does Ultrix have 2 kinds of malloc, while 4.3-tahoe (the first one, I think) only has 1? Here's a little thing I wrote to see how big a chunk I could get from a single malloc... Script started on Fri Jan 6 10:06:45 1989 14 more days of President Reagan % cat tst.c #include #include /* not in 4.3-tahoe */ void main() { char *x; unsigned int i, j; for (i=10000; (x=malloc(i)) != NULL; i+=10000) free(x); i -= 10000; printf("%d\n", i); for (j=i; (x=malloc(j)) != NULL; j+=10) free(x); printf("%d\n", j - 10); } % gcc -O -s -Wall -o tst tst.c tst.c: In function main: tst.c:14: warning: implicit declaration of function `printf' % time tst 4190000 4194300 0.1u 0.3s 0:00 83% 3+19k 0+0io 5pf+0w % gcc -O -s -Wall -o tst tst.c -lmalloc tst.c: In function main: tst.c:14: warning: implicit declaration of function `printf' % time tst 6620000 6619990 0.2u 1.3s 0:01 89% 8+780k 0+0io 9pf+0w % ^D script done on Fri Jan 6 10:08:34 1989 Eh? I thought that there must be some resource limit defined by the system, and in Ultrix (1.2 and 2.2), there is a "ulimit" call, but 4.3-tahoe only has "getrlimit", so I wrote a little smidge to find out what my "RLIMIT_DATA" and "RLIMIT_RSS" were. They were way bigger than the amount I got from malloc. Are they the right thing to check? So I thought mebbe a physical memory limit? Nah, why would I (consistently) get 2 different values depending on the library version I used? Like, what good is virtual memory if I can't malloc New Jersey? ); AND, why did the 3x version (the one used when -lmalloc is included) have such extravagant core(?) requirements - 780k vs. 19k for libc? AND, why isn't there a (old-style) prototype for malloc anywhere in /usr/include, even though it doesn't return an int? Isn't that the way it's supposed to go? Like /usr/include/malloc.h...char *malloc();... Remember, this is the NEOPHYTES group, so keep the fires low. rob