Post · 19 min read· pp. 138–147

Memory Management Glossary: R

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

RAM : Also known as

code
*random access memory*.

RAM (random access memory) is a type of [physical memory
(2)](/u/5195e3271b5de55e#term-physical-memory-2) that can be read from and written to.

Similar term

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

See also

[dynamic RAM](/u/433f84a577790d37#term-dynamic-ram), [ROM](#term-ROM), [static RAM](/u/699ff3e2d070663d#term-static-ram).

random access memory : See

code
[RAM](#term-RAM).

ramp allocation : In the MPS

code
An [allocation pattern](/u/9b03e2fad7c35ce0#term-allocation-pattern) indicating to the MPS that
most of the blocks allocated after the call to
[`mps_ap_alloc_pattern_begin()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/pattern.html#c.mps_ap_alloc_pattern_begin) are likely to be
[dead](/u/433f84a577790d37#term-dead) by the time of the corresponding call to
[`mps_ap_alloc_pattern_end()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/pattern.html#c.mps_ap_alloc_pattern_end). See
[Ramp allocation](https://www.ravenbrook.com/project/mps/master/manual/html/topic/pattern.html#topic-pattern-ramp).

rank : In the MPS

code
A value of [`mps_rank_t`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/root.html#c.mps_rank_t) indicating whether a
[reference](#term-reference) is [ambiguous](/u/9b03e2fad7c35ce0#term-ambiguous-root)
([`mps_rank_ambig()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/root.html#c.mps_rank_ambig)), [exact](/u/43d7e4de9473d658#term-exact-root)
([`mps_rank_exact()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/root.html#c.mps_rank_exact)) or [weak](/u/355fa8e73e689b3a#term-weak-root)
([`mps_rank_weak()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/root.html#c.mps_rank_weak)).

rash : In the MPS

code
A [variety](/u/9b6672e5a107d609#term-variety) in which no MPS functions [assert](/u/9b03e2fad7c35ce0#term-assertion) that their data structures are valid. Select
it by defining [`CONFIG_VAR_RASH`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/error.html#c.CONFIG_VAR_RASH). Compare
[cool](/u/b107b7d39b75ccb0#term-cool) and [hot](/u/5696710a733ccf6f#term-hot).

raw : See

code
[unwrapped](/u/ced5e8494ccaae80#term-unwrapped).

reachable : An object is reachable if it is referred to by a root, or is referred to by a reachable object; that is, if it can be reached from the roots by following references.

code
Reachability is used as an approximation to [liveness](/u/34ad814de80e6063#term-live) in [tracing garbage collection](/u/f992775ea91d0285#term-tracing-garbage-collection).

In [Java](/u/884599c4278a5039#term-java), the [reference objects](#term-reference-object) together with
ordinary references and [finalization](/u/b18026a6b8cfa4c8#term-finalization) generate a
hierarchy of reachability that guides the [collector
(1)](/u/b107b7d39b75ccb0#term-collector-1) on what to do when an object is about to [die](/u/433f84a577790d37#term-dead). There are six strengths:

1. [strongly reachable](/u/699ff3e2d070663d#term-strongly-reachable);
2. [softly reachable](/u/699ff3e2d070663d#term-softly-reachable);
3. [weakly reachable](/u/355fa8e73e689b3a#term-weakly-reachable);
4. [finalizable](/u/b18026a6b8cfa4c8#term-finalization);
5. [phantom reachable](/u/5195e3271b5de55e#term-phantom-reachable);
6. [unreachable](/u/ced5e8494ccaae80#term-unreachable).

Basically, an object is only as reachable as the weakest link
in the strongest path from the roots. Note that the Java
specification’s description of the reachabilities is a bit
patchy, but that’s what it intends. It is unspecified where
Java Native Interface’s *weak global references* fit into
this.

Similar term

[live](/u/34ad814de80e6063#term-live).

Opposite term

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

Related links

[Package java.lang.ref](http://docs.oracle.com/javase/8/docs/api/java/lang/ref/package-summary.html), [Reference Objects and Garbage Collection](http://pawlan.com/monica/articles/refobjs/).

read barrier : A read barrier (1) is a block on reading from certain memory (2) locations by certain threads or processes.

code
Relevance to memory management

Read barriers are used for [incremental](/u/7010622dc3b8d8f9#term-incremental-garbage-collection) or [concurrent](/u/5195e3271b5de55e#term-parallel-garbage-collection) [garbage collection](/u/9334865be20dfda3#term-garbage-collection).

See also

[write barrier](/u/355fa8e73e689b3a#term-write-barrier).

read fault : An exception which occurs when reading from an address in virtual memory.

code
This is probably either a [page fault](/u/5195e3271b5de55e#term-page-fault), an
[invalid page fault](/u/7010622dc3b8d8f9#term-invalid-page-fault) or a [protection fault](/u/5195e3271b5de55e#term-protection-fault).

Similar term

[segmentation violation](/u/699ff3e2d070663d#term-segmentation-violation).

See also

[write fault](/u/355fa8e73e689b3a#term-write-fault).

read-only memory : See

code
[ROM](#term-ROM).

real memory(1) : A system with no virtual memory capability can be said to have real memory.

code
Historical note

On older architectures, programs could only directly
access data in real memory. Where this was inefficient,
they had to store data on disk, and sometimes had
alternate portions of program image called *overlays*.

Opposite term

[virtual memory](/u/9b6672e5a107d609#term-virtual-memory).

real memory(2) : See

code
[physical memory (1)](/u/5195e3271b5de55e#term-physical-memory-1).

reclaim : Reclaiming an object or the memory (1) occupied by it is making it available for reuse after the object is no longer needed.

code
This word is usually used only in connection with
[automatic memory management](/u/9b03e2fad7c35ce0#term-automatic-memory-management).

Similar term

[recycle](#term-recycle).

recycle : Recycling memory (1) means making it available for reuse after it has been occupied by an object that is no longer needed.

code
In simple cases, this might simply involve adding a
[memory (2)](/u/367f5f45f9800ccb#term-memory-2) [block](/u/4c6aaf4e0e0b7eb6#term-block) to the [free list](/u/b18026a6b8cfa4c8#term-free-list).
Another possibility is [unmapping](/u/ced5e8494ccaae80#term-unmapped) memory so
that the [backing store](/u/4c6aaf4e0e0b7eb6#term-backing-store) can be allocated to another
process.

Similar term

[reclaim](#term-reclaim).

reference : In memory management, a reference is the general term for a link from one object to another. Some programming languages have more specific meanings for the term.

code
The terms “[pointer](/u/5195e3271b5de55e#term-pointer)” and “reference” are often
interchangeable, but some programming languages differentiate
the two in subtle ways.

Similar terms

[address](/u/9b03e2fad7c35ce0#term-address), [pointer](/u/5195e3271b5de55e#term-pointer).

In the MPS

A reference is represented in the [C](/u/884599c4278a5039#term-c) interface by a
value of type [`mps_addr_t`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/interface.html#c.mps_addr_t) (an alias for `void
*`) which points to a [memory location](/u/367f5f45f9800ccb#term-memory-location) within the
object (typically the base of the object, but for objects
with [headers](/u/7010622dc3b8d8f9#term-in-band-header) this may not be the
case). The pointer returned by [`mps_alloc()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/allocation.html#c.mps_alloc) and
[`mps_reserve()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/allocation.html#c.mps_reserve) is a reference to the object
allocated.

The [client program](/u/b107b7d39b75ccb0#term-client-program) is free to represent references
as it chooses (for example, with [tags](/u/f992775ea91d0285#term-tagged-reference)), provided that during [scanning](/u/699ff3e2d070663d#term-scan)
it is able to decode a reference from its representation
into the MPS interface representation and encode a
reference from the MPS into its representation.

reference counting : Reference counting systems perform automatic memory management by keeping a count in each object, usually in a header, of how many references there are to the object. Objects to which there are no references cannot be accessed by the mutator; they are therefore dead and may be reclaimed.

code
The reference count is incremented for each new reference, and
is decremented if a reference is overwritten, or if the
referring object is recycled. If a reference count falls to
zero, then the object is no longer required and can be
recycled.

There are four main problems with simple reference counting:

1. The reference count field usually has to have limited size,
   and the system therefore breaks down if the number of
   possible references to an object is unbounded;
2. Reference counting involves an operation on every
   modification of a pointer, which increases code size,
   increases demand for [memory bandwidth](/u/367f5f45f9800ccb#term-memory-bandwidth), decreases
   [locality of reference](/u/34ad814de80e6063#term-locality-of-reference) and can be a serious
   performance penalty (especially in multi-threaded
   environments where reference count updates require
   synchronization);
3. Every object needs to be slightly larger in order to store
   the reference count;
4. If any objects are part of a [cyclic data structure](/u/b107b7d39b75ccb0#term-cyclic-data-structure)
   then they will always have a non-zero reference count, and
   hence won’t be reclaimed when they are dead.

![Diagram: Garbage with non-zero reference counts.](https://cdn.archive.preserve.ng/img/73822d175dc1b0685af1e0cb41181c9b7104fbd3d9c2f02a5e9a3661661d3d9a.svg)

*Garbage with non-zero reference counts.*

Reference counting has the advantage that it can reclaim
objects promptly, and for this reason it is often used to
reclaim non-cyclic data structures in file systems, databases
and operating system kernels. When there is a possibility of
cyclic data structures, reference counting is sometimes used
together with a [tracing garbage collector](/u/f992775ea91d0285#term-tracing-garbage-collection) that runs infrequently. Such combinations
are generally less efficient than using a tracing collector by
itself, but the promptness of reference counting may be
important.

Pauses due to reference counting are typically fairly short,
and it may be appropriate as a form of [incremental
garbage collection](/u/7010622dc3b8d8f9#term-incremental-garbage-collection). But removing a single reference may cause
the recycling of a large number of objects at once, so it is
not suited to real-time systems where minimum pause times must
be guaranteed. There are more complex variations of the
technique that address this problem.

Reference counting is often used because it can be implemented
without any support from the language or compiler. In
[C++](/u/884599c4278a5039#term-1) this can be encapsulated in a class, using a
[smart pointer](/u/699ff3e2d070663d#term-smart-pointer). However, it would normally be more
efficient to use a tracing garbage collector instead. The
performance of reference counting can be improved
substantially with compiler support, using refinements such as
[deferred reference counting](/u/433f84a577790d37#term-deferred-reference-counting), which has been
successfully used in [Smalltalk](/u/884599c4278a5039#term-smalltalk) and other languages.

Despite the problems, reference counting is often used for
[distributed garbage collection](/u/433f84a577790d37#term-distributed-garbage-collection). This is because
refinements such as [weighted reference counting](/u/355fa8e73e689b3a#term-weighted-reference-counting)
require less inter-process communication than [tracing](/u/f992775ea91d0285#term-trace).

See also

[limited-field reference count](/u/34ad814de80e6063#term-limited-field-reference-count), [one-bit reference count](/u/f63e411ec871b42a#term-one-bit-reference-count).

reference object : In Java, a reference object (java.lang.ref.Reference) encapsulates a reference to some other object, in order to make the garbage collector handle it specially. In particular, a Java program can use this to detect when the referent becomes unreachable.

code
Basically, the encapsulated reference is a [weak
reference (1)](/u/355fa8e73e689b3a#term-weak-reference-1); it will be cleared by the [collector
(1)](/u/b107b7d39b75ccb0#term-collector-1) when all other references to the referent have
disappeared. However, in order to better control what happens
at the end of an object’s [lifetime](/u/34ad814de80e6063#term-lifetime), Java 1.2 provides
three classes of reference objects, each with its own
peculiarities: `SoftReference`, `WeakReference`, and
`PhantomReference`. Each of these classes has its uses in
managing memory. The reference objects together with ordinary
references and [finalization](/u/b18026a6b8cfa4c8#term-finalization) generate a hierarchy of
[reachability](#term-reachable) that guides the collector on
what to do when an object is about to [die](/u/433f84a577790d37#term-dead).

A reference object can be *registered* with a queue, and it
will be enqueued when the collector determines that the
referent is [softly](/u/699ff3e2d070663d#term-softly-reachable), [weakly](/u/355fa8e73e689b3a#term-weakly-reachable) or [phantom reachable](/u/5195e3271b5de55e#term-phantom-reachable), as the case
may be. A program can use these queues to perform some action
when an object is dying. This allows finer control than the
older [finalization](/u/b18026a6b8cfa4c8#term-finalization) mechanism alone.

Historical note

This feature was introduced in Java 1.2 (confusingly, part
of the Java 2 Platform).

See also

[phantom reference](/u/5195e3271b5de55e#term-phantom-reference), [soft reference](/u/699ff3e2d070663d#term-soft-reference), [weak reference (2)](/u/355fa8e73e689b3a#term-weak-reference-2).

Related link

[Package java.lang.ref](http://docs.oracle.com/javase/8/docs/api/java/lang/ref/package-summary.html), [Reference Objects and Garbage Collection](http://pawlan.com/monica/articles/refobjs/).

Related publication

[Dybvig et al. (1993)](/u/80406cde1a6844cf#dbe93).

region inference : Region inference is a technique for determining when objects become dead (even if they are reachable) by a static analysis of the program.

code
Region inference infers a *region* for each object. When a
region dies, all the objects in it are known to be
[dead](/u/433f84a577790d37#term-dead), whether reachable or not. Regions obey a strict
[stack](/u/699ff3e2d070663d#term-stack) discipline; that is, when a region dies, all
younger regions also die. In this way, region inference
occupies a middle ground between [stack allocation](/u/699ff3e2d070663d#term-stack-allocation) and
[heap allocation](/u/5696710a733ccf6f#term-heap-allocation).

Related publication

[Tofte & Talpin (1997)](/u/80406cde1a6844cf#tt97).

register : A register is a small unit of memory (2) that is attached to a processor and accessible very quickly. Registers typically form the highest level of a computer’s storage hierarchy.

code
Relevance to memory management

In some programs (for example, those compiled by typical
[C](/u/884599c4278a5039#term-c) or [C++](/u/884599c4278a5039#term-1) compilers), a subset of the
registers is always accessible by the [mutator](/u/367f5f45f9800ccb#term-mutator) and
so forms a [root](#term-root).

In the MPS

The [scan method](/u/699ff3e2d070663d#term-scan-method) for the root containing the
registers is hard to write (it depends on the operating
system, the processor architecture, and in some cases the
compiler), so the MPS provides (on its supported
platforms) the function [`mps_stack_scan_ambig()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/deprecated.html#c.mps_stack_scan_ambig).

register set partitioning : Run-time systems for garbage-collected languages sometimes partition the set of machine registers a priori into two categories: those always traced and updated by the garbage collector and those ignored by it.

code
The former are always maintained in a format understood by the
collector; the latter are never used to hold
[references](#term-reference) to collectable [objects](/u/f63e411ec871b42a#term-object). More
complicated schemes are also possible.

This partitioning provides a separation of concerns between
the compiler and the [garbage collector](/u/9334865be20dfda3#term-garbage-collector). The compiler
can generate code that produces values the garbage collector
would not be able to handle (say, because they have no
[tags](/u/f992775ea91d0285#term-tag)), as long as those values are kept in the
ignored registers. The garbage collector can trust that the
registers it looks at always contain valid data, and can
perform [exact garbage collection](/u/43d7e4de9473d658#term-exact-garbage-collection).

Register set partitioning increases the demand for registers
(*register pressure*), but may reduce the amount of
[boxing](/u/4c6aaf4e0e0b7eb6#term-boxed) needed.

relocation : Relocating means moving data from one location to another and updating all references.

code
Relocation is often performed to avoid [external fragmentation](/u/43d7e4de9473d658#term-external-fragmentation).

Program loading sometimes relocates code and [static](/u/699ff3e2d070663d#term-static-allocation) data.

Similar term

[moving](/u/367f5f45f9800ccb#term-moving-garbage-collector).

See also

[compaction](/u/b107b7d39b75ccb0#term-compaction), [moving memory manager](/u/367f5f45f9800ccb#term-moving-memory-manager).

remembered set : A remembered set is the technique of keeping a separate list of interesting references between two sets of objects, so you don’t have to find them by scanning.

code
Many [memory management](/u/367f5f45f9800ccb#term-memory-management) algorithms depend on
partitioning the objects and require special handling for
references between partitions. Keeping track of such
references in a remembered set eliminates the need to scan the
originating partition to find them.

A typical use in [generational garbage collection](/u/9334865be20dfda3#term-generational-garbage-collection) is
remembering [references](#term-reference) from an older
[generation](/u/9334865be20dfda3#term-generation) to a younger one.

Similar term

[entry table (2)](/u/43d7e4de9473d658#term-entry-table-2).

Related publications

[Ungar (1984)](/u/80406cde1a6844cf#ungar84), [Jones et al. (2012)](/u/80406cde1a6844cf#jones12).

remote reference : In the MPS

code
A [reference](#term-reference) that logically belongs to a
[formatted object](/u/b18026a6b8cfa4c8#term-formatted-object) and so must be [fixed](/u/b18026a6b8cfa4c8#term-fix) when
the object is [scanned](/u/699ff3e2d070663d#term-scan), but which is not
stored within the block containing the object. (For
example, in an auxiliary table of some sort.)

The MPS does not generally support remote references
because those references may be [protected](/u/5195e3271b5de55e#term-protection) and so if [scan method](/u/699ff3e2d070663d#term-scan-method) attempts to
[fix](/u/b18026a6b8cfa4c8#term-fix) them this will hit a [barrier (1)](/u/4c6aaf4e0e0b7eb6#term-barrier-1) and
cause a re-entrant call to the MPS.

replicating garbage collector : A variant of copying garbage collection, which does not destroy the original object when making a copy.

code
This is useful in an [incremental](/u/7010622dc3b8d8f9#term-incremental-garbage-collection) or [concurrent](/u/5195e3271b5de55e#term-parallel-garbage-collection) [collector (1)](/u/b107b7d39b75ccb0#term-collector-1), as no [read barrier](#term-read-barrier)
is required; the [mutator](/u/367f5f45f9800ccb#term-mutator) can continue to use old
objects. The collector uses a [write barrier](/u/355fa8e73e689b3a#term-write-barrier) to
replicate the writes to the new copies.

See also

[broken heart](/u/4c6aaf4e0e0b7eb6#term-broken-heart), [copying garbage collection](/u/b107b7d39b75ccb0#term-copying-garbage-collection).

Related publications

[Nettles et al. (1992)](/u/80406cde1a6844cf#noph92), [Nettles & O’Toole (1993)](/u/80406cde1a6844cf#no93), [Nettles & O’Toole (1993a)](/u/80406cde1a6844cf#no93a), [O’Toole & Nettles (1994)](/u/80406cde1a6844cf#on94).

reserved : In a virtual memory system, it is usually possible to hold range of virtual addresses reserved without making it mapped.

code
Reserving addresses prevents other components of the program
using the same addresses, without consuming [swap
space](/u/699ff3e2d070663d#term-swap-space). This technique is often used in [BIBOP](/u/4c6aaf4e0e0b7eb6#term-bibop) schemes,
where one might want to reserve a large amount of
[address space](/u/9b03e2fad7c35ce0#term-address-space) but only sparsely map it.

On some systems there are special calls for reserving; on
others one can create [mappings](/u/367f5f45f9800ccb#term-mapping) that don’t
need [backing store](/u/4c6aaf4e0e0b7eb6#term-backing-store). For example, on some Unix systems,
`mmap /dev/zero` with no access.

See also

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

In the MPS

The function [`mps_arena_reserved()`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/arena.html#c.mps_arena_reserved) returns the
total address space reserved by an arena.

resident : In a cache (2) system, that part of the cached storage which currently has a copy in the cache is called resident. Ideally, the working set should be resident.

code
See also

[cache (2)](/u/b107b7d39b75ccb0#term-cache-2), [resident set](#term-resident-set), [storage hierarchy](/u/699ff3e2d070663d#term-storage-hierarchy).

resident set : In a virtual memory system, a process’ resident set is that part of a process’ address space which is currently in main memory. If this does not include all of the process’ working set, the system may thrash.

result code : In the MPS

code
A value returned from an MPS function, represented by the
type [`mps_res_t`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/error.html#c.mps_res_t). The result code
[`MPS_RES_OK`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/error.html#c.MPS_RES_OK) indicates success; other values
indicate errors. See [Error handing](https://www.ravenbrook.com/project/mps/master/manual/html/topic/error.html#topic-error).

resurrection : An object is said to have been resurrected if it was determined to be finalizable by the garbage collector (that is, the only thing keeping it alive was the fact that it required finalization), but then a new strong reference was created to it.

code
This can happen via a [weak reference (1)](/u/355fa8e73e689b3a#term-weak-reference-1) or by the
finalization procedure storing a permanent copy of its
reference to the object.

In the MPS

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

retention : The failure to recycle floating garbage, due to some approximation or optimization in the garbage collector; also the amount of memory thus retained.

code
Related publication

[Boehm (2001)](/u/80406cde1a6844cf#boehm01).

ROM : Also known as

code
*read-only memory*.

ROM (read-only memory) is a type of [physical memory
(2)](/u/5195e3271b5de55e#term-physical-memory-2) that can be read from, but not written to. The contents
of ROM are usually set in the factory.

See also

[RAM](#term-RAM).

root : In tracing garbage collection, a root holds a reference or set of references to objects that are a priori reachable. The root set is used as the starting point in determining all reachable data.

code
Roots basically comprise the references in the state of the
[mutator](/u/367f5f45f9800ccb#term-mutator). Typical roots are global variables, other
[static](/u/699ff3e2d070663d#term-static-allocation) data, and the
[control stack](/u/b107b7d39b75ccb0#term-control-stack).

See also

[ambiguous root](/u/9b03e2fad7c35ce0#term-ambiguous-root), [exact root](/u/43d7e4de9473d658#term-exact-root), [strong root](/u/699ff3e2d070663d#term-strong-root), [weak root](/u/355fa8e73e689b3a#term-weak-root).

In the MPS

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

root description : In the MPS

code
The [arena](/u/9b03e2fad7c35ce0#term-arena) uses root descriptions to find
[references](#term-reference) within the [client
program’s](/u/b107b7d39b75ccb0#term-client-program) [roots](#term-root). Root
descriptions belong to the type [`mps_root_t`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/root.html#c.mps_root_t).

root mode : In the MPS

code
A value of type [`mps_rm_t`](https://www.ravenbrook.com/project/mps/master/manual/html/topic/root.html#c.mps_rm_t) describing whether a
[root](#term-root) is [constant](/u/b107b7d39b75ccb0#term-constant-root),
[protectable](/u/5195e3271b5de55e#term-protectable-root), or both. The root
mode tells the MPS whether it may place a [barrier
(1)](/u/4c6aaf4e0e0b7eb6#term-barrier-1) on the root.

root set : The root set is the collection of roots that the mutator declares to the collector (2).

code
See also

[garbage collection](/u/9334865be20dfda3#term-garbage-collection).