Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / share / doc / papers / malloc / alternatives.ms
1 .\"
2 .\" ----------------------------------------------------------------------------
3 .\" "THE BEER-WARE LICENSE" (Revision 42):
4 .\" <phk@login.dknet.dk> wrote this file.  As long as you retain this notice you
5 .\" can do whatever you want with this stuff. If we meet some day, and you think
6 .\" this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7 .\" ----------------------------------------------------------------------------
8 .\"
9 .\" $FreeBSD: src/share/doc/papers/malloc/alternatives.ms,v 1.5 1999/08/28 00:18:09 peter Exp $
10 .\" $DragonFly: src/share/doc/papers/malloc/alternatives.ms,v 1.2 2003/06/17 04:36:56 dillon Exp $
11 .\"
12 .ds RH Alternative implementations
13 .NH
14 Alternative implementations
15 .PP
16 These problems were actually the inspiration for the first alternative
17 malloc implementations.
18 Since their main aim was debugging, they would often use techniques
19 like allocating a guard zone before and after the chunk,
20 and possibly filling these guard zones
21 with some pattern, so accesses outside the allocated chunk could be detected
22 with some decent probability.
23 Another widely used technique is to use tables to keep track of which
24 chunks are actually in which state and so on.
25 .PP
26 This class of debugging has been taken to its practical extreme by
27 the product "Purify" which does the entire memory-colouring exercise
28 and not only keeps track of what is in use and what isn't, but also
29 detects if the first reference is a read (which would return undefined
30 values) and other such violations.
31 .PP
32 Later actual complete implementations of malloc arrived, but many of
33 these still based their workings on the basic schema mentioned previously,
34 disregarding that in the meantime virtual memory and paging have
35 become the standard environment.
36 .PP
37 The most widely used "alternative" malloc is undoubtedly ``gnumalloc''
38 which has received wide acclaim and certainly runs faster than
39 most stock mallocs.  It does, however, tend to fare badly in
40 cases where paging is the norm rather than the exception.
41 .PP
42 The particular malloc that prompted this work basically didn't bother 
43 reusing storage until the kernel forced it to do so by refusing 
44 further allocations with sbrk(2).
45 That may make sense if you work alone on your own personal mainframe,
46 but as a general policy it is less than optimal.