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