memory_stats Tcl Built-In Commands 8.3

NAME

memory_stats - Tcl memory allocation statistics

SYNOPSIS

memory_stats

DESCRIPTION

The memory_stats command is available in Hume customized versions of Tcl when the Tcl interpreter has been compiled to use its own memory allocation logic, and the MSTATS macro is true (compile flags -DUSE_TCL_ALLOC=1 and -DMSTATS (see generic/tclAlloc.c)). The command result provides information on the amount and sizes of memory blocks that have been allocated, are in active use, or are free. Tcl does not return small sized allocated memory to the system so it is often of interest to know to what degree allocated memory has been freed and is being retained for future use. The command result provides a list of named values.

% memory_stats
{freelist_counters {0 658 247 124 239 21 0 30 8 5 6 2 1}} \
{in_use {0 1390 3849 5508 273 235 128 66 56 51 14 0 0}} \
{total_small_free 244608} {total_small_in_use 1164416} \
{total_smalls_and_overhead 1512312} {big_in_use_count 0}

The named values have the following meanings:

freelist_counters
The 13 numbers represent counts of memory blocks that have been allocated and then freed for future use. The counts are for the sequence of rounded-up allocation sizes of 8, 16, 32, ..., (2^15). Because of the per-allocation overhead which also allows for memory alignment, the smallest size may not be in use.
in_use
The 13 numbers represent counts of memory blocks that are in active use, ordered from smallest to largest.
total_small_free
This is the total amount of free memory which is computed by summing the product of the free counters and their sizes.
total_small_in_use
This is the total amount of active memory represented by the in_use counters and using their respective sizes.
total_smalls_and_overhead
This figure is the sum of the small free memory, the small active memory, and the amount of memory consumed by allocation overhead.
big_in_use_count
Memory blocks that are larger than 32k are allocated separately, and returned to the system when free. This count shows how many big blocks are in use.

SEE ALSO

ckalloc, ckfree, memory, Tcl_ValidateAllMemory, Tcl_DumpActiveMemory, TCL_MEM_DEBUG

AUTHOR

The memory_stats command has been created by Hume Integration Software and is not part of the ordinary Tcl/Tk distribution.

KEYWORDS

memory, debug