Tcl_DumpActiveMemory(3)
π Tcl_DumpActiveMemory(3) π
okay bestie, welcome to the Tcl Library Procedures corner of the group chat β this one's the validated memory allocation interface and it's genuinely such a slay for anyone debugging memory. it's Tcl_DumpActiveMemory, Tcl_InitMemory, and Tcl_ValidateAllMemory, and no cap, they're all about peeking at what your allocator is doing. β¨
πΈ NAME πΈ
Tcl_DumpActiveMemory, Tcl_InitMemory, Tcl_ValidateAllMemory β the validated memory allocation interface, aka your backstage pass to Tcl's memory debugging tea π«
π SYNOPSIS π
#include <tcl.h>
int
Tcl_DumpActiveMemory(fileName)
Tcl_InitMemory(interp)
Tcl_ValidateAllMemory(fileName, line)
π ARGUMENTS π
Tcl_Interp *interp(in) β the Tcl interpreter where we're gonna add commands. that's it, that's the whole vibe.const char *fileName(in) β forTcl_DumpActiveMemory, this is the name of the file the memory info gets written to. forTcl_ValidateAllMemory, it's the name of the file the call is being made from (normally__FILE__).int line(in) β the line number where the call toTcl_ValidateAllMemoryhappens (normally__LINE__).
π¦ DESCRIPTION π¦
so these functions hand you the keys to Tcl's memory debugging info. but listen: 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 are literally no-ops. nothing. dead. π
Tcl_DumpActiveMemory outputs a list of every currently allocated chunk of memory to the file you specify. for each allocated block of memory, the info it spits out is: the starting and ending addresses (excluding the guard zone, important!!), the size, the source file where Tcl_Alloc was called to allocate that block, and the line number in that file. pro move: calling Tcl_DumpActiveMemory after the Tcl interpreter has been deleted? iconic. chef's kiss. π
Tcl_InitMemory adds the Tcl memory command to the interpreter given by interp. and fun fact β Tcl_InitMemory is called by Tcl_Main.
Tcl_ValidateAllMemory forces a validation of the guard zones of all currently allocated blocks of memory. normally a block gets validated when it's freed, unless full validation is enabled β in which case validation of all blocks happens whenever Tcl_Alloc and Tcl_Free are called. this function just forces that validation to happen at any point you want. very "I said what I said" energy. π
π SEE ALSO π
TCL_MEM_DEBUGmemory
β KEYWORDS β
- memory
- debug
and that's the whole page, bestie β stay validated, keep those guard zones safe, and may your dumps always be active. π§ββοΈ
this was Tcl 8.1 bringing you Tcl_DumpActiveMemory(3) β k bye, love u, mwah π«Άπ
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- 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