Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/memory.n @ 42

Last change on this file since 42 was 25, checked in by landauf, 17 years ago

added tcl to libs

File size: 4.3 KB
Line 
1'\"
2'\" Copyright (c) 1992-1999 by Karl Lehenbauer and Mark Diekhans
3'\" Copyright (c) 2000 by Scriptics Corporation.
4'\" All rights reserved.
5'\"
6'\" RCS: @(#) $Id: memory.n,v 1.12 2008/01/18 15:51:08 dkf Exp $
7'\"
8.so man.macros
9.TH memory n 8.1 Tcl "Tcl Built-In Commands"
10.BS
11.SH NAME
12memory \- Control Tcl memory debugging capabilities
13.SH SYNOPSIS
14\fBmemory \fIoption \fR?\fIarg arg ...\fR?
15.BE
16.SH DESCRIPTION
17.PP
18The \fBmemory\fR command gives the Tcl developer control of Tcl's memory
19debugging capabilities.  The memory command has several suboptions, which are
20described below.  It is only available when Tcl has been compiled with
21memory debugging enabled (when \fBTCL_MEM_DEBUG\fR is defined at
22compile time), and after \fBTcl_InitMemory\fR has been called.
23.TP
24\fBmemory active\fR \fIfile\fR
25.
26Write a list of all currently allocated memory to the specified \fIfile\fR.
27.TP
28\fBmemory break_on_malloc\fR \fIcount\fR
29.
30After the \fIcount\fR allocations have been performed, \fBckalloc\fR
31outputs a message to this effect and that it is now attempting to enter
32the C debugger.  Tcl will then issue a \fISIGINT\fR signal against itself.
33If you are running Tcl under a C debugger, it should then enter the debugger
34command mode.
35.TP
36\fBmemory info\fR
37.
38Returns a report containing the total allocations and frees since
39Tcl began, the current packets allocated (the current
40number of calls to \fBckalloc\fR not met by a corresponding call
41to \fBckfree\fR), the current bytes allocated, and the maximum number
42of packets and bytes allocated.
43.TP
44\fB memory init \fR[\fBon\fR|\fBoff\fR]
45.
46Turn on or off the pre-initialization of all allocated memory
47with bogus bytes.  Useful for detecting the use of uninitialized values.
48.TP
49\fBmemory onexit\fR \fIfile\fR
50.
51Causes a list of all allocated memory to be written to the specified \fIfile\fR
52during the finalization of Tcl's memory subsystem.  Useful for checking
53that memory is properly cleaned up during process exit.
54.TP
55\fBmemory tag\fR \fIstring\fR
56.
57Each packet of memory allocated by \fBckalloc\fR can have associated
58with it a string-valued tag.  In the lists of allocated memory generated
59by \fBmemory active\fR and \fBmemory onexit\fR, the tag for each packet
60is printed along with other information about the packet.  The
61\fBmemory tag\fR command sets the tag value for subsequent calls
62to \fBckalloc\fR to be \fIstring\fR. 
63.TP
64\fBmemory trace \fR[\fBon\fR|\fBoff\fR]
65.
66Turns memory tracing on or off.  When memory tracing is on, every call
67to \fBckalloc\fR causes a line of trace information to be written to
68\fIstderr\fR, consisting of the word \fIckalloc\fR, followed by the
69address returned, the amount of memory allocated, and the C filename
70and line number of the code performing the allocation.  For example:
71.RS
72.CS
73ckalloc 40e478 98 tclProc.c 1406
74.CE
75Calls to \fBckfree\fR are traced in the same manner.
76.RE
77.TP
78\fBmemory trace_on_at_malloc\fR \fIcount\fR
79.
80Enable memory tracing after \fIcount\fR \fBckalloc\fRs have been performed.
81For example, if you enter \fBmemory trace_on_at_malloc 100\fR,
82after the 100th call to \fBckalloc\fR, memory trace information will begin
83being displayed for all allocations and frees.  Since there can be a lot
84of memory activity before a problem occurs, judicious use of this option
85can reduce the slowdown caused by tracing (and the amount of trace information
86produced), if you can identify a number of allocations that occur before
87the problem sets in.  The current number of memory allocations that have
88occurred since Tcl started is printed on a guard zone failure.
89.TP
90\fBmemory validate \fR[\fBon\fR|\fBoff\fR]
91.
92Turns memory validation on or off. When memory validation is enabled,
93on every call to \fBckalloc\fR or \fBckfree\fR, the guard zones are
94checked for every piece of memory currently in existence that was
95allocated by \fBckalloc\fR.  This has a large performance impact and
96should only be used when overwrite problems are strongly suspected.
97The advantage of enabling memory validation is that a guard zone
98overwrite can be detected on the first call to \fBckalloc\fR or
99\fBckfree\fR after the overwrite occurred, rather than when the
100specific memory with the overwritten guard zone(s) is freed, which may
101occur long after the overwrite occurred.
102.SH "SEE ALSO"
103ckalloc, ckfree, Tcl_ValidateAllMemory, Tcl_DumpActiveMemory, TCL_MEM_DEBUG
104.SH KEYWORDS
105memory, debug
Note: See TracBrowser for help on using the repository browser.