> < ^ Date: Mon, 22 Sep 1997 16:40:50 +0100
> < ^ From: Steve Linton <sal@dcs.st-and.ac.uk >
< ^ Subject: Re: Lists With Holes

Some recipients may have received this before. It was sent using an obsolete
alias, and does not appear to have been sent on to the whole GAP forum.

Dear Mathias,

You asked about the memory used by lists. There is no entirely
simple answer, but the basic situation is the following:

Most objects in GAP are represented by a pointer to a bag.
Each bag uses up 12 bytes of memory in addition to its contents.
The exception is integers less than 2^28 in absolute magnitude,
which are represented by themselves (slightly encoded).

Apart from the 12 byte overhead for its bag, and 4 bytes for the
length, a list uses 4 bytes for every entry, whether or not bound.
An entry which is not a small integer will also use up memory for
its own bag overhead and data. Special arrangements apply for
Boolean lists and vectors.

For example, a list of length 10000, in which each entry is a small
integer or unbound, will use up 40016 bytes, regardless of how many
entries are bound. On the other hand, the same list filled with
"small" rationals (numerator and denominator small integers) will
use 40016+ 10000*(12 + 8) = 240016 bytes.

In other words, an unbound entry uses the same space as a small
integer entry, but they both use much less space than any other
kind of entry.

Steve Linton


> < [top]