Re: Memory problems

From: Stewart Forster <>
Date: Fri, 29 Nov 1996 09:24:22 +1100

> According to Martin Gleeson:
> > As far as I'm aware, no implementations of malloc do this. They just free
> > the memory back to malloc for the next time you ask for it. To free it back
> > to the OS would require some sort of hook in the OS to handle that sort of
> > thing. And I'm not aware of any OS/malloc combos that will do this. But of
> > course I reserve the right to be completely wrong :-)
> GNUmalloc is supposed to do that with sbrk(2).

        sbrk(2) is only used for claiming memory, not releasing it back to
the system. At least this is the case on every MAJOR OS that I've seen.

> Phkmalloc in FreeBSD 2.2 is doing the same with the use of madvice(2) and
> telling FreeBSD that the poage is free and usable by the VM system.

        madvise(2) I understood to be a paging adviser to the kernel.
Basically you're saying to the kernel, "I've allocated this page with sbrk(2),
but I don't really need it right now, so page it out for me until I page fault
on it in the future". Basically it puts the page straight into the `pages to
be paged out' list.

Stewart Forster (Security and Web Proxy Cache Administrator) pty ltd, Level 9, 114 Albert Rd, Sth Melbourne, VIC 3205, Aust.
Email:   Phone: +61 3 9251-3684   Fax: +61 3 9251-3666
Received on Thu Nov 28 1996 - 14:28:49 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:33:40 MST