memory.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
- '"
- '" Copyright (c) 1992-1999 by Karl Lehenbauer and Mark Diekhans
- '" Copyright (c) 2000 by Scriptics Corporation.
- '" All rights reserved.
- '"
- '" RCS: @(#) $Id: memory.n,v 1.5 2002/11/15 15:34:17 dkf Exp $
- '"
- .so man.macros
- .TH memory n 8.1 Tcl "Tcl Built-In Commands"
- .BS
- .SH NAME
- memory - Control Tcl memory debugging capabilities.
- .SH SYNOPSIS
- fBmemory fIoption fR?fIarg arg ...fR?
- .BE
- .SH DESCRIPTION
- .PP
- The fBmemoryfR command gives the Tcl developer control of Tcl's memory
- debugging capabilities. The memory command has several suboptions, which are
- described below. It is only available when Tcl has been compiled with
- memory debugging enabled (when fBTCL_MEM_DEBUGfR is defined at
- compile time), and after fBTcl_InitMemoryfR has been called.
- .TP
- fBmemory activefR fIfilefR
- Write a list of all currently allocated memory to the specified fIfilefR.
- .TP
- fBmemory break_on_mallocfR fIcountfR
- After the fIcountfR allocations have been performed, fBckallocfR
- outputs a message to this effect and that it is now attempting to enter
- the C debugger. Tcl will then issue a fISIGINTfR signal against itself.
- If you are running Tcl under a C debugger, it should then enter the debugger
- command mode.
- .TP
- fBmemory infofR
- Returns a report containing the total allocations and frees since
- Tcl began, the current packets allocated (the current
- number of calls to fBckallocfR not met by a corresponding call
- to fBckfreefR), the current bytes allocated, and the maximum number
- of packets and bytes allocated.
- .TP
- fB memory init [on|off]fR
- Turn on or off the pre-initialization of all allocated memory
- with bogus bytes. Useful for detecting the use of uninitialized values.
- .TP
- fBmemory onexitfR fIfilefR
- Causes a list of all allocated memory to be written to the specified fIfilefR
- during the finalization of Tcl's memory subsystem. Useful for checking
- that memory is properly cleaned up during process exit.
- .TP
- fBmemory tagfR fIstringfR
- Each packet of memory allocated by fBckallocfR can have associated
- with it a string-valued tag. In the lists of allocated memory generated
- by fBmemory activefR and fBmemory onexitfR, the tag for each packet
- is printed along with other information about the packet. The
- fBmemory tagfR command sets the tag value for subsequent calls
- to fBckallocfR to be fIstringfR.
- .TP
- fBmemory trace [on|off]fR
- .br
- Turns memory tracing on or off. When memory tracing is on, every call
- to fBckallocfR causes a line of trace information to be written to
- fIstderrfR, consisting of the word fIckallocfR, followed by the
- address returned, the amount of memory allocated, and the C filename
- and line number of the code performing the allocation. For example:
- .RS
- .CS
- ckalloc 40e478 98 tclProc.c 1406
- .CE
- Calls to fBckfreefR are traced in the same manner.
- .RE
- .TP
- fBmemory trace_on_at_mallocfR fIcountfR
- Enable memory tracing after fIcountfR fBckallocfR's have been performed.
- For example, if you enter fBmemory trace_on_at_malloc 100fR,
- after the 100th call to fBckallocfR, memory trace information will begin
- being displayed for all allocations and frees. Since there can be a lot
- of memory activity before a problem occurs, judicious use of this option
- can reduce the slowdown caused by tracing (and the amount of trace information
- produced), if you can identify a number of allocations that occur before
- the problem sets in. The current number of memory allocations that have
- occurred since Tcl started is printed on a guard zone failure.
- .TP
- fBmemory validate [on|off]fR
- Turns memory validation on or off. When memory validation is enabled,
- on every call to fBckallocfR or fBckfreefR, the guard zones are
- checked for every piece of memory currently in existence that was
- allocated by fBckallocfR. This has a large performance impact and
- should only be used when overwrite problems are strongly suspected.
- The advantage of enabling memory validation is that a guard zone
- overwrite can be detected on the first call to fBckallocfR or
- fBckfreefR after the overwrite occurred, rather than when the
- specific memory with the overwritten guard zone(s) is freed, which may
- occur long after the overwrite occurred.
- .SH "SEE ALSO"
- ckalloc, ckfree, Tcl_ValidateAllMemory, Tcl_DumpActiveMemory, TCL_MEM_DEBUG
- .SH KEYWORDS
- memory, debug