home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!centerline!noc.near.net!news.Brown.EDU!qt.cs.utexas.edu!yale.edu!jvnc.net!darwin.sura.net!mips!pacbell.com!decwrl!parc!boehm
- From: boehm@parc.xerox.com (Hans Boehm)
- Subject: Re: good memory allocation strategies?
- Message-ID: <boehm.711834865@siria>
- Keywords: SGI kernel
- Sender: news@parc.xerox.com
- Organization: Xerox PARC
- References: <1992Jul21.214115.28569@tamsun.tamu.edu> <1992Jul22.172111.2646@hyper.hyper.com>
- Date: 22 Jul 92 19:54:25 GMT
- Lines: 46
-
- hurst@hyper.hyper.com (Graham Hurst) writes:
-
- >In article <1992Jul21.214115.28569@tamsun.tamu.edu> tsmith@cs.tamu.edu writes:
- >...
- >>I am working on a moderate size (~10000 lines so far) system on an SGI
- >>workstation running UNIX system V.3, and I am wondering about some
- >>memory allocation issues. [Rest deleted]
-
- >Beware of using memory allocation on SGI computers!
-
- >We recently discovered a "feature" of the default SGI kernel that makes
- >dynamic memory allocation unreliable - it never turns down a request for
- >memory!
-
- >Since IRIX 3.3.2, the default SGI kernel will cause malloc/realloc
- >(via sbrk) to return a non-zero pointer even if the requested memory size is
- >greater than the sum of physical memory and swap space! If your app tries
- >to use enough of this memory, the kernel sends a SIGKILL to kill your app
- >and puts a message on the console about running out of swap space.
-
- This does increase the probability of crashes due to running out of
- swap space. But the traditional way of checking malloc results is
- already somewhat unreliable under most circumstances. Consider
- the following scenario:
-
- malloc(enough space to barely fit in swap space);
- call deeply recursive procedure;
-
- On most systems that I know of, your process now gets sent a bus error due
- to the inability of the kernel to grow your process stack sufficiently.
- You can try to avoid this by growing the stack sufficiently in the beginning,
- and catching any bus errors that occur; but if it weren't for the
- particularly poor choice of SIGKILL, you could do the analogous thing
- for malloc. (AIX gives you a warning signal first, before it sends
- SIGKILL, I believe. This initially struck me as silly, but I'm begginning
- to believe that it's more useful than any of the other alternatives,
- including the one in which malloc preallocates swap space.)
-
- Note that similar problems occur if there are other crucial processes
- allocating swap space on the same machine. Copy-on-write pages for
- shared libararies are yet another problem. Malloc is only one consumer
- of swap space.
-
- Hans-J. Boehm
- (boehm@parc.xerox.com)
-
-