Options

Options for StatsCollector defined below. Each enables during compilation one specific counter, statistic, or other piece of information.

Values

ValueMeaning
numOwns1u << 0

Counts the number of calls to owns.

numAllocate1u << 1

Counts the number of calls to allocate. All calls are counted, including requests for zero bytes or failed requests.

numAllocateOK1u << 2

Counts the number of calls to allocate that succeeded, i.e. they returned a block as large as requested. (N.B. requests for zero bytes count as successful.)

numExpand1u << 3

Counts the number of calls to expand, regardless of arguments or result.

numExpandOK1u << 4

Counts the number of calls to expand that resulted in a successful expansion.

numReallocate1u << 5

Counts the number of calls to reallocate, regardless of arguments or result.

numReallocateOK1u << 6

Counts the number of calls to reallocate that succeeded. (Reallocations to zero bytes count as successful.)

numReallocateInPlace1u << 7

Counts the number of calls to reallocate that resulted in an in-place reallocation (no memory moved). If this number is close to the total number of reallocations, that indicates the allocator finds room at the current block's end in a large fraction of the cases, but also that internal fragmentation may be high (the size of the unit of allocation is large compared to the typical allocation size of the application).

numDeallocate1u << 8

Counts the number of calls to deallocate.

numDeallocateAll1u << 9

Counts the number of calls to deallocateAll.

numAll(1u << 10) - 1

Chooses all numXxx flags.

bytesUsed1u << 10

Tracks bytes currently allocated by this allocator. This number goes up and down as memory is allocated and deallocated, and is zero if the allocator currently has no active allocation.

bytesAllocated1u << 11

Tracks total cumulative bytes allocated by means of allocate, expand, and reallocate (when resulting in an expansion). This number always grows and indicates allocation traffic. To compute bytes deallocated cumulatively, subtract bytesUsed from bytesAllocated.

bytesExpanded1u << 12

Tracks the sum of all delta values in calls of the form expand(b, delta) that succeed (return true).

bytesContracted1u << 13

Tracks the sum of all b.length - s with b.length > s in calls of the form realloc(b, s) that succeed (return true). In per-call statistics, also unambiguously counts the bytes deallocated with deallocate.

bytesMoved1u << 14

Tracks the sum of all bytes moved as a result of calls to realloc that were unable to reallocate in place. A large number (relative to bytesAllocated) indicates that the application should use larger preallocations.

bytesNotMoved1u << 15

Tracks the sum of all bytes NOT moved as result of calls to realloc that managed to reallocate in place. A large number (relative to bytesAllocated) indicates that the application is expansion-intensive and is saving a good amount of moves. However, if this number is relatively small and bytesSlack is high, it means the application is overallocating for little benefit.

bytesSlack1u << 16

Measures the sum of extra bytes allocated beyond the bytes requested, i.e. the internal fragmentation. This is the current effective number of slack bytes, and it goes up and down with time.

bytesHighTide1u << 17

Measures the maximum bytes allocated over the time. This is useful for dimensioning allocators.

bytesAll((1u << 18) - 1) & ~numAll

Chooses all byteXxx flags.

all(1u << 18) - 1

Combines all flags above.

Meta