Post · 15 min read· pp. 78–86

Memory Management Glossary: F

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

fencepost

fence post : A fencepost is spare memory (1) between allocated blocks for checking purposes.

code
Some [memory management](/u/367f5f45f9800ccb#term-memory-management) systems leave spare memory
between allocated blocks and store special values in it. If a
checking routine finds that these memory [locations](/u/367f5f45f9800ccb#term-memory-location) have been modified, this probably indicates
an [overwriting error](/u/f63e411ec871b42a#term-overwriting-error) in the application that was
allocated the adjacent block.

Such checking can help application programmers to find bugs
that would otherwise be difficult to reproduce and track down.

Similar term

[in-band header](/u/7010622dc3b8d8f9#term-in-band-header).

In the MPS

[Debugging pools](/u/433f84a577790d37#term-debugging-pool) use fenceposts. See
[Debugging pools](https://www.ravenbrook.com/project/mps/master/manual/html/topic/debugging.html#topic-debugging).

fencepost error

fence post error : The term fencepost error refers to errors arising from the fact that, to enclose n consecutive intervals, you need n + 1 end-points, from the number of posts required to support fence rails.

code
An example of a fencepost error would be, in [C](/u/884599c4278a5039#term-c):

```c

void f(void) { int i; int a[10]; for(i = 0; i <= 10; i++) a[i] = 0; }

code

    because the declaration `int a[10];` creates an array of ten
    integers, with indices from 0 to 9, but the `for` loop index
    `i` runs from 0 to 10.

Fibonacci buddies
:   A common [buddy system](/u/4c6aaf4e0e0b7eb6#term-buddy-system) [allocation mechanism](/u/9b03e2fad7c35ce0#term-allocation-mechanism), in
    which block sizes form a Fibonacci series (each block size is
    the sum of the two previous sizes). Each block can therefore
    be [split](/u/699ff3e2d070663d#term-split) to form two blocks of valid sizes, and the
    sizes are more closely spaced than in [binary buddies](/u/4c6aaf4e0e0b7eb6#term-binary-buddies).
    However, if the same size is allocated repeatedly, performance
    may suffer as the remainder blocks may have to be split again
    (or become fragments).

    See also

    [allocation mechanism](/u/9b03e2fad7c35ce0#term-allocation-mechanism), [buddy system](/u/4c6aaf4e0e0b7eb6#term-buddy-system).

    Related publication

    [Wilson et al. (1995)](/u/80406cde1a6844cf#wil95).

<a id="term-FIFO-ordered-first-fit"></a>FIFO-ordered first fit
:   The [allocation policy](/u/9b03e2fad7c35ce0#term-allocation-policy) that always uses the
    least-recently [freed (1)](#term-free-1) suitable [free
    block](#term-free-block). Commonly implemented by adding freed blocks to the end
    of a [free block chain](#term-free-block-chain), and then using [first
    fit](#term-first-fit) allocation on this chain. [free (1)](#term-free-1) can be very
    quick, depending on the [coalescing](/u/b107b7d39b75ccb0#term-coalesce) policy.

    According to [Wilson et al. (1995)](/u/80406cde1a6844cf#wil95), this policy
    controls fragmentation quite well, better than
    [LIFO-ordered first fit](/u/34ad814de80e6063#term-lifo-ordered-first-fit) and as well as
    [address-ordered first fit](/u/9b03e2fad7c35ce0#term-address-ordered-first-fit) in some cases, although
    [locality](/u/34ad814de80e6063#term-locality-of-reference) may be worse.

file mapping
:   See

    [memory mapping](/u/367f5f45f9800ccb#term-memory-mapping).

finalization
:   Also known as

    *termination*.

    In [garbage-collected](/u/9334865be20dfda3#term-garbage-collection) languages,
    it is often necessary to perform actions on some
    [objects](/u/f63e411ec871b42a#term-object) after they are no longer in use and
    before their [memory (2)](/u/367f5f45f9800ccb#term-memory-2) can be [recycled](/u/611c5a77bde93a2f#term-recycle). These actions are known as *finalization* or
    *termination*.

    A common use of finalization is to release resources when the
    corresponding “proxy” object dies. For example, an open file
    might be represented by a stream object. When this object has
    been proven [dead](/u/433f84a577790d37#term-dead) by the [collector (1)](/u/b107b7d39b75ccb0#term-collector-1), it is
    certain that the file is no longer in use by the program, and
    it can and should be closed before the stream is recycled.

    Note that finalization is not, in general, guaranteed to be
    prompt, and this can cause problems if it is used to manage
    scarce operating system resources such as file descriptors.

    Many object-oriented languages provide support for
    finalization, for example, Cedar, [Java](/u/884599c4278a5039#term-java), [Perl](/u/884599c4278a5039#term-perl)
    5, and [Smalltalk](/u/884599c4278a5039#term-smalltalk).

    The term *finalization* is sometimes used to refer to the use
    of [destructors (1)](/u/433f84a577790d37#term-destructor-1), for example in Ada.

    In the MPS

    See [Finalization](https://www.ravenbrook.com/project/mps/master/manual/html/topic/finalization.html#topic-finalization).

finalized block
:   In the MPS

    A [block](/u/4c6aaf4e0e0b7eb6#term-block) that has been registered for finalization
    using [`mps_finalize()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/finalization.html#c.mps_finalize), and which the MPS has
    determined is [dead](/u/433f84a577790d37#term-dead), but whose finalization message
    has not been discarded. See
    [`mps_message_type_finalization()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/finalization.html#c.mps_message_type_finalization).

<a id="term-first-fit"></a>first fit
:   First fit is a [sequential fit](/u/699ff3e2d070663d#term-sequential-fit) [allocation
    mechanism](/u/9b03e2fad7c35ce0#term-allocation-mechanism).

    To quote [Wilson et al. (1995)](/u/80406cde1a6844cf#wil95):

    > First fit simply searches the [free list](#term-free-list) from the
    > beginning, and uses the first [free block](#term-free-block) large
    > enough to satisfy the request. If the block is larger than
    > necessary, it is split and the remainder is put on the
    > free list.

    The first fit mechanism provides a class of first fit
    [allocation policies](/u/9b03e2fad7c35ce0#term-allocation-policy), depending on the order in which
    the free list is stored. [Address-ordered first fit](/u/9b03e2fad7c35ce0#term-address-ordered-first-fit)
    stores the list in order of (usually increasing) address.
    [LIFO-ordered first fit](/u/34ad814de80e6063#term-lifo-ordered-first-fit) puts blocks on the front of the
    free list when they are [freed (1)](#term-free-1). [FIFO-ordered
    first fit](#term-FIFO-ordered-first-fit) puts blocks on the end of the free list when they
    are [freed (1)](#term-free-1).

    See also

    [address-ordered first fit](/u/9b03e2fad7c35ce0#term-address-ordered-first-fit), [best fit](/u/4c6aaf4e0e0b7eb6#term-best-fit), [FIFO-ordered first fit](#term-FIFO-ordered-first-fit), [LIFO-ordered first fit](/u/34ad814de80e6063#term-lifo-ordered-first-fit), [next fit](/u/79d1d3e473607e01#term-next-fit), [sequential fit](/u/699ff3e2d070663d#term-sequential-fit), [worst fit](/u/355fa8e73e689b3a#term-worst-fit).

fix
:   In the MPS

    To *fix* a [reference](/u/611c5a77bde93a2f#term-reference) from one [block](/u/4c6aaf4e0e0b7eb6#term-block) to
    another is to declare it to the MPS by calling
    [`MPS_FIX1()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/scanning.html#c.MPS_FIX1) and [`MPS_FIX2()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/scanning.html#c.MPS_FIX2) within a
    [scan method](/u/699ff3e2d070663d#term-scan-method). In a [moving](/u/367f5f45f9800ccb#term-moving-garbage-collector) [pool](/u/5195e3271b5de55e#term-pool), fixing a reference may also
    update it to point to the new location of the block. See
    [Scanning](https://www.ravenbrook.com/project/mps/master/manual/html/topic/scanning.html#topic-scanning).

flip
:   The instant in a [two-space collector](/u/f992775ea91d0285#term-two-space-collector) when the roles of
    the two [semi-spaces](/u/699ff3e2d070663d#term-semi-space) are reversed. What
    was the [tospace](/u/f992775ea91d0285#term-tospace) is now marked as [fromspace](#term-fromspace) and
    [condemned](/u/b107b7d39b75ccb0#term-condemned-set). What was the fromspace
    becomes the site for all new [allocations](/u/9b03e2fad7c35ce0#term-allocate). Also used in a more general sense to mean the
    initiation of a new [collection cycle](/u/b107b7d39b75ccb0#term-collection-cycle).

    ![Diagram: In a two-space collector, the *flip* occurs just before the fromspace is condemned and copying starts.](https://cdn.archive.preserve.ng/img/1958c3a1bd3698e21eb086fb81c138d0430e0eb6fc0eead1f9371ed74121748d.svg)

    *In a two-space collector, the *flip* occurs just before the
    fromspace is condemned and copying starts.*

floating garbage
:   Floating garbage is [garbage](/u/9334865be20dfda3#term-garbage) that is not
    [recycled](/u/611c5a77bde93a2f#term-recycle) promptly due to some approximation
    or optimization in the [garbage collector](/u/9334865be20dfda3#term-garbage-collector).

    Floating garbage results from conservatively estimating an
    [object](/u/f63e411ec871b42a#term-object) that is really [unreachable](/u/ced5e8494ccaae80#term-unreachable) to be
    [reachable](/u/611c5a77bde93a2f#term-reachable) for the purposes of a particular
    [collection cycle](/u/b107b7d39b75ccb0#term-collection-cycle). Using estimates can have
    considerable performance benefits but also result in higher
    [memory (2)](/u/367f5f45f9800ccb#term-memory-2) consumption.

    Typical estimates that cause floating garbage are:

    1. Every register or [activation frame](/u/9b03e2fad7c35ce0#term-activation-frame) slot holds a
       reachable value: this is not always true, as objects stored
       in dead registers or slots may be otherwise unreachable.
       This estimate can simplify the compiler as well as the
       interface between the compiler and the garbage collector.
    2. Every object in a [remembered set](/u/611c5a77bde93a2f#term-remembered-set) is reachable: this
       is not always true, because remembered objects can have
       become unreachable since they were added to the remembered
       set. This estimate allows remembered sets to be effective;
       the alternative—determining whether each remembered object
       is reachable—is equivalent to a full garbage collection.
    3. Anything that looks like a [reference](/u/611c5a77bde93a2f#term-reference) is one: this
       is not generally true, because random data can have the
       same bit pattern as a pointer. [Conservative garbage
       collectors](/u/b107b7d39b75ccb0#term-conservative-garbage-collection) use this
       estimate.
    4. Any object referenced from another is reachable: this is
       not generally true, because garbage can reference other
       garbage. [Reference counting](/u/611c5a77bde93a2f#term-reference-counting) collectors use this
       estimate, resulting in their not being able to reclaim
       self-referential structures.
    5. Any object reached during collection remains live until the
       next collection: this may not be true when the garbage
       collector runs interleaved with the mutator, as do
       [incremental](/u/7010622dc3b8d8f9#term-incremental-garbage-collection) and
       [concurrent](/u/5195e3271b5de55e#term-parallel-garbage-collection)
       collectors.

    A more subtle kind of floating garbage is an unreachable data
    structure that spans multiple regions that are never
    [condemned](/u/b107b7d39b75ccb0#term-condemned-set) together.

foreign code
:   In the MPS

    From the point of view of the [client program](/u/b107b7d39b75ccb0#term-client-program),
    *foreign code* is external code (not part of the client
    program, or the MPS), which is not aware of and does not
    co-operate with the MPS. The client program must take care
    when passing the address of a block in a [moving](/u/367f5f45f9800ccb#term-moving-memory-manager) [pool](/u/5195e3271b5de55e#term-pool) to foreign code.

    The [LO (Leaf Object)](https://www.ravenbrook.com/project/mps/master/manual/html/pool/lo.html#pool-lo) [pool class](/u/5195e3271b5de55e#term-pool-class) is designed for this
    use case: blocks allocated from this pool do not move and
    are never protected, and so may be passed safely to
    foreign code.

format
:   A format describes the representation of an [object](/u/f63e411ec871b42a#term-object);
    that is, how the object is laid out in memory.

    A format usually specifies where the fields of the objects are
    located and what their type is.

    Relevance to memory management

    If formats are provided by a language or the application
    program, [exact garbage collection](/u/43d7e4de9473d658#term-exact-garbage-collection) can be used,
    because the [collector (1)](/u/b107b7d39b75ccb0#term-collector-1) can determine which
    fields are [references](/u/611c5a77bde93a2f#term-reference).

    See also

    [conservative garbage collection](/u/b107b7d39b75ccb0#term-conservative-garbage-collection).

<a id="term-format-method"></a>format method
:   In the MPS

    One of the methods in an [object format](/u/f63e411ec871b42a#term-object-format), defined by
    the [client program](/u/b107b7d39b75ccb0#term-client-program) in order to describe its
    objects to the MPS. May be a [scan method](/u/699ff3e2d070663d#term-scan-method),
    [skip method](/u/699ff3e2d070663d#term-skip-method), [forward method](#term-forward-method),
    [is-forwarded method](/u/7010622dc3b8d8f9#term-is-forwarded-method), or [padding method](/u/5195e3271b5de55e#term-padding-method).

<a id="term-formatted-object"></a>formatted object
:   In the MPS

    An allocated [block](/u/4c6aaf4e0e0b7eb6#term-block) that belongs to an
    [object format](/u/f63e411ec871b42a#term-object-format) and may be [scanned](/u/699ff3e2d070663d#term-scan) by
    the [garbage collector](/u/9334865be20dfda3#term-garbage-collector). See [Object formats](https://www.ravenbrook.com/project/mps/master/manual/html/topic/format.html#topic-format).

<a id="term-forward-method"></a>forward method
:   In the MPS

    A [format method](#term-format-method) that is called by a [moving](/u/367f5f45f9800ccb#term-moving-garbage-collector) [pool](/u/5195e3271b5de55e#term-pool) when it
    has moved an object. The forward method replaces the old
    object with a [forwarding marker](#term-forwarding-marker) that points to the
    new location of the object. See [`mps_fmt_fwd_t`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/format.html#c.mps_fmt_fwd_t).

<a id="term-forwarding-marker"></a>forwarding marker

forwarding object

forwarding pointer
:   Some [garbage collectors](/u/9334865be20dfda3#term-garbage-collector)
    [move](/u/367f5f45f9800ccb#term-moving-garbage-collector) [reachable](/u/611c5a77bde93a2f#term-reachable)
    [objects](/u/f63e411ec871b42a#term-object) into another space. They leave a
    forwarding pointer, a special [reference](/u/611c5a77bde93a2f#term-reference) pointing to
    the new [location](/u/367f5f45f9800ccb#term-memory-location), in the old
    location.

    Similar term

    [broken heart](/u/4c6aaf4e0e0b7eb6#term-broken-heart).

    See also

    [copying garbage collection](/u/b107b7d39b75ccb0#term-copying-garbage-collection), [two-space collector](/u/f992775ea91d0285#term-two-space-collector).

    In the MPS

    The term *forwarding object* is used. This is a
    [formatted object](#term-formatted-object) that has been replaced by a
    [forwarding marker](#term-forwarding-marker). One of three types of formatted
    objects, the other two being [client objects](/u/b107b7d39b75ccb0#term-client-object) and
    [padding objects](/u/5195e3271b5de55e#term-padding-object).

fragmentation
:   Fragmentation is the inability to use [memory (1)](/u/367f5f45f9800ccb#term-memory-1)
    because of the arrangement of memory already in use. It is
    usually divided into [external fragmentation](/u/43d7e4de9473d658#term-external-fragmentation) and
    [internal fragmentation](/u/7010622dc3b8d8f9#term-internal-fragmentation).

    Related publication

    [Johnstone & Wilson (1998)](/u/80406cde1a6844cf#jw98).

frame
:   See

    [in-band header](/u/7010622dc3b8d8f9#term-in-band-header).

<a id="term-free-1"></a>free<sup>(1)</sup>
:   Also known as

    *deallocate*.

    In [manual memory management](/u/367f5f45f9800ccb#term-manual-memory-management), to free or deallocate an
    [object](/u/f63e411ec871b42a#term-object) is to tell the [memory manager](/u/367f5f45f9800ccb#term-memory-manager) that it
    is no longer needed. The [memory (1)](/u/367f5f45f9800ccb#term-memory-1) may then be
    [recycled](/u/611c5a77bde93a2f#term-recycle) by being used for subsequent
    [allocation](/u/9b03e2fad7c35ce0#term-allocate), or by being returned to the
    operating system.

    Opposite term

    [allocate](/u/9b03e2fad7c35ce0#term-allocate).

    See also

    [destructor (1)](/u/433f84a577790d37#term-destructor-1), [free (2)](#term-free-2).

<a id="term-free-2"></a>free<sup>(2)</sup>
:   In [C](/u/884599c4278a5039#term-c), the system function used for explicit
    [deallocation](#term-free-1) is called `free`.

<a id="term-free-3"></a>free<sup>(3)</sup>
:   [Memory (2)](/u/367f5f45f9800ccb#term-memory-2) is *free* if it is not currently
    [allocated](/u/9b03e2fad7c35ce0#term-allocate).

    Historical note

    The term *available* was commonly used to mean “free”.

    Opposite term

    [allocated](/u/9b03e2fad7c35ce0#term-allocate).

    See also

    [free (1)](#term-free-1).

free<sup>(4)</sup>
:   See

    [unmapped](/u/ced5e8494ccaae80#term-unmapped).

<a id="term-free-block"></a>free block
:   A single contiguous area of [memory (2)](/u/367f5f45f9800ccb#term-memory-2) available to
    satisfy an [allocation](/u/9b03e2fad7c35ce0#term-allocate) request.

    For the purpose of discussing [allocation mechanisms](/u/9b03e2fad7c35ce0#term-allocation-mechanism),
    two adjacent free blocks are not considered to be a single
    free block, until they are [coalesced](/u/b107b7d39b75ccb0#term-coalesce). Free blocks may
    be [split](/u/699ff3e2d070663d#term-split).

    See also

    [allocation mechanism](/u/9b03e2fad7c35ce0#term-allocation-mechanism), [free list](#term-free-list).

    Related publication

    [Wilson et al. (1995)](/u/80406cde1a6844cf#wil95).

<a id="term-free-block-chain"></a>free block chain
:   Some systems store the [free list](#term-free-list) as a linked list, or
    chain.

    Usually the links are stored within the [free (3)](#term-free-3)
    [blocks](/u/4c6aaf4e0e0b7eb6#term-block). This means that all [allocated](/u/9b03e2fad7c35ce0#term-allocate) blocks
    must be large enough to store these, and implies a minimum
    size.

    Sometimes, the free block chain is ordered by [address](/u/9b03e2fad7c35ce0#term-address).
    This makes [coalescence](/u/b107b7d39b75ccb0#term-coalesce) considerably
    cheaper, but [deallocation](#term-free-1) more expensive.

    See also

    [free list](#term-free-list).

<a id="term-free-list"></a>free list
:   The free list is the set of [free blocks](#term-free-block).

    Originally this term meant the single linked list of all free
    blocks, but as [allocation mechanisms](/u/9b03e2fad7c35ce0#term-allocation-mechanism) have become more
    varied, it has become more generic, and now may be implemented
    as a tree or other data structure rather than a linked list.
    If the implementation actually is a linked list of free
    blocks, this is called a [free block chain](#term-free-block-chain) to
    distinguish it from the abstract term.

    There may be several free lists, classed by size or other
    characteristic. For instance, [segregated free list](/u/699ff3e2d070663d#term-segregated-free-list)
    systems classify free lists by block size.

    See also

    [free block](#term-free-block), [free block chain](#term-free-block-chain).

freestanding
:   In the [C](/u/884599c4278a5039#term-c) programming language as defined by
    [C90](/u/b107b7d39b75ccb0#term-c90), a freestanding implementation “accepts any
    strictly conforming program in which the use of the features
    specified in the library section is confined to the contents
    of the standard headers `<float.h>`, `<limits.h>`,
    `<stdarg.h>`, and `<stddef.h>`.” The [C99](/u/b107b7d39b75ccb0#term-c99) standard
    adds `<iso646.h>`, `<stdbool.h>`, and `<stdint.h>` to
    this list.

    In particular, a freestanding implementation need not provide
    the other features of the standard C library, including I/O,
    time, and string operations.

    Opposite term

    [hosted](/u/5696710a733ccf6f#term-hosted).

    In the MPS

    The MPS is designed to be portable to a freestanding
    implementation, by restricting the use of other features
    either to [platform](/u/5195e3271b5de55e#term-platform)-specific modules or to the
    replaceable [plinth](/u/5195e3271b5de55e#term-plinth) modules.

    Related publications

    [ISO/IEC 9899:1990](https://www.ravenbrook.com/project/mps/master/manual/html/design/stack-scan.html#c1990), [ISO/IEC 9899:1999](https://www.ravenbrook.com/project/mps/master/manual/html/design/stack-scan.html#c1999).

free store

freestore
:   See

    [heap](/u/5696710a733ccf6f#term-heap).

from space

<a id="term-fromspace"></a>fromspace
:   Also known as

    *old space*, *oldspace*.

    In [copying garbage collection](/u/b107b7d39b75ccb0#term-copying-garbage-collection), the space containing a
    mixture of [live](/u/34ad814de80e6063#term-live) and [dead](/u/433f84a577790d37#term-dead) objects, out of which
    the former are copied.

    Opposite term

    [tospace](/u/f992775ea91d0285#term-tospace).

function pointer
:   In the [C](/u/884599c4278a5039#term-c) programming language, a [pointer](/u/5195e3271b5de55e#term-pointer) to an
    function, as distinct from a [object pointer](/u/f63e411ec871b42a#term-object-pointer). The C
    programming language does not guarantee that function and
    object pointers are the same size, or that a pointer of one
    type can be cast to a pointer of the other type without
    losing information (but on every mainstream C implementation,
    including all those supported by the MPS, they are in fact the
    same).

    Opposite term

    [object pointer](/u/f63e411ec871b42a#term-object-pointer).

function record
:   See

    [activation record](/u/9b03e2fad7c35ce0#term-activation-record).