Tcl_DumpActiveMemory(3)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– 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) β€” for Tcl_DumpActiveMemory, this is the name of the file the memory info gets written to. for Tcl_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 to Tcl_ValidateAllMemory happens (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_DEBUG
  • memory

⭐ 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