Tcl_DumpActiveMemory(3tcl)
π Tcl_DumpActiveMemory β the validated memory allocation interface, bestie π
okay so this is a Tcl Library Procedures page, and it's about three little functions that let you peek inside Tcl's memory-debugging brain: Tcl_DumpActiveMemory, Tcl_InitMemory, and Tcl_ValidateAllMemory. Together they're the validated memory allocation interface. grab a snack, we're going in π
β¨ SYNOPSIS β¨
#include <tcl.h>
int
Tcl_DumpActiveMemory(fileName)
Tcl_InitMemory(interp)
Tcl_ValidateAllMemory(fileName, line)
π ARGUMENTS π
Tcl_Interp *interp(in) β the Tcl interpreter you want to add commands to. that's it, that's the vibe.const char *fileName(in) β forTcl_DumpActiveMemory, this is the name of the file that memory info gets written to. forTcl_ValidateAllMemory, it's the name of the file the call is coming from (normally__FILE__). same name, two whole jobs, multitasking icon πint line(in) β the line number where theTcl_ValidateAllMemorycall happens (normally__LINE__).
π DESCRIPTION π
so these functions give you access to Tcl memory debugging info. major caveat incoming: they only actually do anything when Tcl has been compiled with TCL_MEM_DEBUG defined at compile-time. when TCL_MEM_DEBUG is not defined, all of these functions are no-ops. literally just vibing and doing nothing. no cap.
Tcl_DumpActiveMemory outputs a list of all currently allocated memory to the specified file. for each allocated block of memory, the info it spits out is:
- starting and ending addresses (excluding the guard zone, okay bestie, not the guard zone)
- size
- the source file where
Tcl_Allocwas called to allocate that block - the line number in that file
it's especially useful to call Tcl_DumpActiveMemory after the Tcl interpreter has been deleted. like, that's the moment. that's when the tea gets spilled π«β¨
Tcl_InitMemory adds the Tcl memory command to the interpreter given by interp. and fun fact: Tcl_InitMemory is called by Tcl_Main. so it's already out here living its life in the wild.
Tcl_ValidateAllMemory forces a validation of the guard zones of all currently allocated blocks of memory. normally, validation of a block happens when it's freed β unless full validation is enabled, in which case validation of all blocks happens when Tcl_Alloc and Tcl_Free are called. this function forces that validation to occur at any point you want. you're the main character, you pick the moment π
π SEE ALSO π
TCL_MEM_DEBUGmemory
π¦ KEYWORDS π¦
memory, debug
and that's the whole page, bestie π this one's from the Tcl crew, version 8.1 β the Tcl_DumpActiveMemory(3tcl) girlies stay validated, stay allocated, and stay free of guard-zone shenanigans. mwah ππ
β¨
π¦ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 1992-1999 Karl Lehenbauer & Mark Diekhans
- Copyright (c) 2000 Scriptics Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms