1memory(n)                    Tcl Built-In Commands                   memory(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       memory - Control Tcl memory debugging capabilities
9

SYNOPSIS

11       memory option ?arg arg ...?
12______________________________________________________________________________
13

DESCRIPTION

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 objs file
45              Causes a list of all allocated Tcl_Obj values to be  written  to
46              the  specified  file  immediately, together with where they were
47              allocated.  Useful for checking for leaks of values.
48
49       memory onexit file
50              Causes a list of all allocated memory to be written to the spec‐
51              ified  file  during  the finalization of Tcl's memory subsystem.
52              Useful for checking that memory is properly  cleaned  up  during
53              process exit.
54
55       memory tag string
56              Each  packet  of memory allocated by ckalloc can have associated
57              with it a string-valued tag.  In the lists of  allocated  memory
58              generated  by  memory active and memory onexit, the tag for each
59              packet is printed along with other information about the packet.
60              The  memory  tag command sets the tag value for subsequent calls
61              to ckalloc to be string.
62
63       memory trace [on|off]
64              Turns memory tracing on or off.   When  memory  tracing  is  on,
65              every  call  to ckalloc causes a line of trace information to be
66              written to stderr, consisting of the word ckalloc,  followed  by
67              the  address returned, the amount of memory allocated, and the C
68              filename and line number of the code performing the  allocation.
69              For example:
70
71                     ckalloc 40e478 98 tclProc.c 1406
72
73              Calls to ckfree are traced in the same manner.
74
75       memory trace_on_at_malloc count
76              Enable  memory tracing after count ckallocs have been performed.
77              For example, if you enter memory trace_on_at_malloc  100,  after
78              the  100th  call to ckalloc, memory trace information will begin
79              being displayed for all allocations and frees.  Since there  can
80              be  a  lot of memory activity before a problem occurs, judicious
81              use of this option can reduce the  slowdown  caused  by  tracing
82              (and the amount of trace information produced), if you can iden‐
83              tify a number of allocations that occur before the problem  sets
84              in.  The current number of memory allocations that have occurred
85              since Tcl started is printed on a guard zone failure.
86
87       memory validate [on|off]
88              Turns memory validation on or off.  When  memory  validation  is
89              enabled, on every call to ckalloc or ckfree, the guard zones are
90              checked for every piece of memory currently  in  existence  that
91              was  allocated  by ckalloc.  This has a large performance impact
92              and should only be used when  overwrite  problems  are  strongly
93              suspected.   The advantage of enabling memory validation is that
94              a guard zone overwrite can be detected  on  the  first  call  to
95              ckalloc or ckfree after the overwrite occurred, rather than when
96              the specific memory with the overwritten guard zone(s) is freed,
97              which may occur long after the overwrite occurred.
98

SEE ALSO

100       ckalloc,     ckfree,    Tcl_ValidateAllMemory,    Tcl_DumpActiveMemory,
101       TCL_MEM_DEBUG
102

KEYWORDS

104       memory, debug
105
106
107
108Tcl                                   8.1                            memory(n)
Impressum