Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!thyme!kaleb From: kaleb@thyme.jpl.nasa.gov (Kaleb Keithley ) Newsgroups: comp.unix.questions Subject: Re: alloca, malloc and friends Keywords: alloca, malloc Message-ID: <1990Oct25.152414.8221@thyme.jpl.nasa.gov> Date: 25 Oct 90 15:24:14 GMT References: <6793@suns302.cel.co.uk> Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 22 In article <6793@suns302.cel.co.uk> ir@cel.co.uk (ian reid) writes: > >The problem is that there is no way that this memory can be returned to the >operating system, at least no way documented on the sbrk(2) manual page which is >where I would expect to find it, after all free(3) is documented on the malloc >page. free simply returns the memory to the pool managed by malloc not to the >operating system, the documented behaviour. sbrk may be passed a negative number, effectively shrinking the data segment size, although no implementation of malloc/free that I know of will do this. You could always roll your own malloc/free that does return free'd memory to the system this way. Good starting points are any of the malloc/free sources in gnu emacs, perl, or gwm. All three of these are based on the 4.3 bsd malloc/free, massaged by Caltech, and then polished by Stallman, Wall, and Nahaboo respectively. -- Kaleb Keithley Jet Propulsion Labs kaleb@thyme.jpl.nasa.gov causing trouble again.