On Tue, Oct 22, 2002 at 01:20:42AM -0700, Terry Lambert wrote: > The FreeBSD malloc uses anonymous pages mmap'ed off of /dev/zero. > > The Linux malloc uses pages added to the process address space via > a call to sbrk.
There is no "Linux malloc", neither does Linux have a sbrk syscall :) But glibc malloc indeed uses both brk and mmap. > The FreeBSD malloc guarantees that the pages are zeroed before being > obtained from the system; this is probably the majority of the cost. > It is a security measure, so that you do not leak data from one process > to another through anonymous pages. > > The Linux malloc does not. glibc malloc doesn not guarantee you zeroed memory if you reuse memory that was freed in your process. Otherwise it's of course zeroed. > once on allocation, once again on checking of the reference, after). > > The FreeBSD malloc references an environment variable and a readlink() > of a potentially non-existant symbolic link containing configuration > data for the malloc. > > The Linux malloc does not have this overhead. glibc malloc reads a bunch of enviroment variables, though to allow stuff like memleak debuging and such > The FreeBSD malloc would be lower performance than the Linux malloc, > if you allocate space in teeny, tiny chunks; it has much higher > performance for large allocations. Good programmers allocate their > resources up front, once, instead of doing the allocations in time > critical internal loops. It's certainly debatable wehther the whole point of a userlevel memory allocator like malloc() isn't avoiding the reimlementation of a better allocator in each an every program :) To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message