1memory(n) Tcl Built-In Commands memory(n)
2
3
4
5______________________________________________________________________________
6
8 memory - Control Tcl memory debugging capabilities
9
11 memory option ?arg arg ...?
12_________________________________________________________________
13
15 The memory command gives the Tcl developer control of Tcl's memory
16 debugging capabilities. The memory command has several suboptions,
17 which are described below. It is only available when Tcl has been com‐
18 piled with memory debugging enabled (when TCL_MEM_DEBUG is defined at
19 compile time), and after Tcl_InitMemory has been called.
20
21 memory active file
22 Write a list of all currently allocated memory to the specified
23 file.
24
25 memory break_on_malloc count
26 After the count allocations have been performed, ckalloc outputs
27 a message to this effect and that it is now attempting to enter
28 the C debugger. Tcl will then issue a SIGINT signal against
29 itself. If you are running Tcl under a C debugger, it should
30 then enter the debugger command mode.
31
32 memory info
33 Returns a report containing the total allocations and frees
34 since Tcl began, the current packets allocated (the current num‐
35 ber of calls to ckalloc not met by a corresponding call to
36 ckfree), the current bytes allocated, and the maximum number of
37 packets and bytes allocated.
38
39 memory init [on|off]
40 Turn on or off the pre-initialization of all allocated memory
41 with bogus bytes. Useful for detecting the use of uninitialized
42 values.
43
44 memory onexit file
45 Causes a list of all allocated memory to be written to the spec‐
46 ified file during the finalization of Tcl's memory subsystem.
47 Useful for checking that memory is properly cleaned up during
48 process exit.
49
50 memory tag string
51 Each packet of memory allocated by ckalloc can have associated
52 with it a string-valued tag. In the lists of allocated memory
53 generated by memory active and memory onexit, the tag for each
54 packet is printed along with other information about the packet.
55 The memory tag command sets the tag value for subsequent calls
56 to ckalloc to be string.
57
58 memory trace [on|off]
59 Turns memory tracing on or off. When memory tracing is on,
60 every call to ckalloc causes a line of trace information to be
61 written to stderr, consisting of the word ckalloc, followed by
62 the address returned, the amount of memory allocated, and the C
63 filename and line number of the code performing the allocation.
64 For example:
65 ckalloc 40e478 98 tclProc.c 1406
66 Calls to ckfree are traced in the same manner.
67
68 memory trace_on_at_malloc count
69 Enable memory tracing after count ckallocs have been performed.
70 For example, if you enter memory trace_on_at_malloc 100, after
71 the 100th call to ckalloc, memory trace information will begin
72 being displayed for all allocations and frees. Since there can
73 be a lot of memory activity before a problem occurs, judicious
74 use of this option can reduce the slowdown caused by tracing
75 (and the amount of trace information produced), if you can iden‐
76 tify a number of allocations that occur before the problem sets
77 in. The current number of memory allocations that have occurred
78 since Tcl started is printed on a guard zone failure.
79
80 memory validate [on|off]
81 Turns memory validation on or off. When memory validation is
82 enabled, on every call to ckalloc or ckfree, the guard zones are
83 checked for every piece of memory currently in existence that
84 was allocated by ckalloc. This has a large performance impact
85 and should only be used when overwrite problems are strongly
86 suspected. The advantage of enabling memory validation is that
87 a guard zone overwrite can be detected on the first call to
88 ckalloc or ckfree after the overwrite occurred, rather than when
89 the specific memory with the overwritten guard zone(s) is freed,
90 which may occur long after the overwrite occurred.
91
93 ckalloc, ckfree, Tcl_ValidateAllMemory, Tcl_DumpActiveMemory,
94 TCL_MEM_DEBUG
95
97 memory, debug
98
99
100
101Tcl 8.1 memory(n)