home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!uunet.ca!hyper.hyper.com!hurst
- From: hurst@hyper.hyper.com (Graham Hurst)
- Subject: Re: good memory allocation strategies?
- Message-ID: <1992Jul22.172111.2646@hyper.hyper.com>
- Summary: Dynamic memory allocation is unsafe with default SGI kernel
- Keywords: SGI kernel
- Sender: hurst@hyper.com (Graham Hurst)
- Reply-To: hurst@hyper.com (Graham Hurst)
- Organization: HyperCube Inc.
- References: <1992Jul21.214115.28569@tamsun.tamu.edu>
- Date: Wed, 22 Jul 1992 17:21:11 GMT
- Lines: 35
-
- 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.
-
- I know (but don't agree with) SGI's reasons for making the change in their
- kernel, and I know non-portable workarounds that help (including reconfiguring
- the kernel). Even if you roll-your-own memory management, many GL calls use
- malloc.
-
- SGI told me that Mach and OSF/1 act the same way (i.e. allow fork/exec/sbrk
- requests greater than swap+physical). Can anyone confirm?
-
- This behaviour precludes portable and otherwise robust software (employing
- the good coding practice of checking the return value of malloc) from
- executing reliably on SGIs. I believe it is also at odds with the ANSI C
- standard (can't quote it directly, but K&R II suggests if one gets a non-zero
- pointer one can use the memory).
-
- Graham Hurst
- Hypercube Inc, 7-419 Phillip St, Waterloo, Ont, Canada N2L 3X2 (519)725-4040
- internet: hurst@hyper.com
-