Re: Memory allocation errors

Richard B. Johnson (
Tue, 28 Jan 1997 12:45:42 -0500 (EST)

On Tue, 28 Jan 1997, Mark Hemment wrote:

> Richard B. Johnson wrote:
> > From info received here, I decided to make my own check of a
> > possible memory allocation bug. I can confirm that the bug does,
> > indeed, exist.
> Not a bug!

Okay. Then what is the purpose of this __FEATURE___? This is defininitely
a BUG and a BUG of the worse possible kind.

> malloc() and free() are library funcs, not system calls.

Exactly what I stated in the message. I also stated that it wasn't a
kernel bug. I also stated where the BUG existed. I also suggested that
the maintainer of the C runtime library look into this.

> malloc() may sbrk() up the data segment to get more memory,
> but not all implementations of free() will sbrk() down. Therefore
> free()d memory will not be returned to the OS, but will stay in a
> process's address space.
> For malloc engines which use sbrk() and can return memory to the
> system, the conditions which allow this are limited.

Not true. This is the __FIRST__ operating system I have ever used that
refuses to do this. Even Borland returns RAM to DOS when the last
pointer is freed. I have applications running on IRMX that could not
possibly work unless memory was truly freed. It is often not possible
to set the break address down until the LAST allocation unit is freed,
however, once it is freed it is always possible.

> If you need to allocate/free a large block of memory, and have it
> returned to the system, mmap()/unmap() anonymous memory.

POSIX defines malloc() and free() for user-mode dynamic memory
allocation and _deallocation_.

If memory isn't freed, here's another "denial of services" ...

> > I can run the first program forever on my Sun (SunOS 5.5.1). This
> > machine, in spite of its many problems, does deallocate RAM when
> > free() is called.
> It is possible to write malloc()/free() to use mmap()/unmap(), maybe
> SunOS 5.5.1 does this (but then again, maybe not).
> Regards,
> markhe

Dick Johnson
Richard B. Johnson
Project Engineer
Analogic Corporation
Voice : (508) 977-3000 ext. 3754
Fax : (508) 532-6097
Modem : (508) 977-6870
Ftp :
Email :,
Penguin : Linux version 2.1.23 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.