free(2) doesn't give free -- what ??

Alex Martelli martelli at cadlab.sublink.ORG
Mon Apr 29 22:32:17 AEST 1991


weis at netmbx.UUCP (Dietmar Weis) writes:
	...
:Free(2) frees memory in a running process, but no other process can use it 
:then.
free(2) ?  Try "man 2 free" and you'll get "No entry for free in section 2 of
the manual"...  it's actually free(3), that is, a SUBROUTINE, *NOT* a system
call, and it's built on top of brk(2) [or sbrk(2), same manual entry:-].
That's not nitpicking - it may be the key to a solution for your problem: you
can rewrite the malloc/realloc/free routine-set, using brk(2) not just to get
more memory when needed, but also to give it back to the system when possible.
You can start with the memory-allocator example in Kernighan and Ritchie's
"The C Programming Language", or with any of several more advanced packages,
such as Conor Cahill's "Debugging-Malloc", Roberto Buratti's "High speed
memory allocator", Larry Wall's own malloc() (from the PERL package), etc
etc, all posted at one time or another on various sources groups.
-- 
Alex Martelli - CAD.LAB s.p.a., v. Stalingrado 53, Bologna, Italia
Email: (work:) martelli at cadlab.sublink.org, (home:) alex at am.sublink.org
Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; 
Fax: ++39 (51) 366964 (work only), Fidonet: 332/401.3 (home only).



More information about the Comp.unix.ultrix mailing list