Unix Programming - malloc implementation

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > December 2006 > malloc implementation





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author malloc implementation
Rob Hoelz

2006-12-18, 7:22 pm

Hello,

I've been curious about the implementation of malloc lately. I have an
idea about how the allocator keeps track of free space vs used space,
but how are the size and start of the data segment discovered?

Thanks!

--
-Rob Hoelz
matevzb

2006-12-18, 7:22 pm

On Dec 18, 9:11 pm, Rob Hoelz <h...@wisc.edu> wrote:
> I've been curious about the implementation of malloc lately. I have an
> idea about how the allocator keeps track of free space vs used space,
> but how are the size and start of the data segment discovered?

A commonly used implementation is at
http://g.oswego.edu/dl/html/malloc.html along with algorithm
explanation. A word of warning though, the source is a whopping 175 K
in size =)
--
WYCIWYG - what you C is what you get

William Ahern

2006-12-18, 7:22 pm

On Mon, 18 Dec 2006 14:11:12 -0600, Rob Hoelz wrote:

> Hello,
>
> I've been curious about the implementation of malloc lately. I have an
> idea about how the allocator keeps track of free space vs used space,
> but how are the size and start of the data segment discovered?
>
> Thanks!


Read the man pages for end(), brk(), and sbrk() for the traditional
approach.

A common, more recent strategy is simply for the allocator to use anonymous
mmap() regions. In this case, the allocator knows the length, but the start
of the region is determined entirely by the kernel and returned by the
mmap() call upon each invocation.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com