90 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <HTML><HEAD><TITLE>Tcl Built-In Commands - memory manual page</TITLE></HEAD><BODY>
 | |
| <DL>
 | |
| <DD><A HREF="memory.htm#M2" NAME="L704">NAME</A>
 | |
| <DL><DD>memory - Control Tcl memory debugging capabilities.</DL>
 | |
| <DD><A HREF="memory.htm#M3" NAME="L705">SYNOPSIS</A>
 | |
| <DL>
 | |
| <DD><B>memory </B><I>option </I>?<I>arg arg ...</I>?
 | |
| <DD>
 | |
| </DL>
 | |
| <DD><A HREF="memory.htm#M4" NAME="L706">DESCRIPTION</A>
 | |
| <DL>
 | |
| <DD><A HREF="memory.htm#M5" NAME="L707"><B>memory info</B></A>
 | |
| <DD><A HREF="memory.htm#M6" NAME="L708"><B>memory trace [on|off]</B></A>
 | |
| <DD><A HREF="memory.htm#M7" NAME="L709"><B>memory validate [on|off]</B></A>
 | |
| <DD><A HREF="memory.htm#M8" NAME="L710"><B>memory trace_on_at_malloc</B> <I>count</I></A>
 | |
| <DD><A HREF="memory.htm#M9" NAME="L711"><B>memory break_on_malloc</B> <I>count</I></A>
 | |
| <DD><A HREF="memory.htm#M10" NAME="L712"><B> memory display</B> <I>file</I></A>
 | |
| </DL>
 | |
| <DD><A HREF="memory.htm#M11" NAME="L713">SEE ALSO</A>
 | |
| <DD><A HREF="memory.htm#M12" NAME="L714">KEYWORDS</A>
 | |
| </DL><HR>
 | |
| <H3><A NAME="M2">NAME</A></H3>
 | |
| memory - Control Tcl memory debugging capabilities.
 | |
| <H3><A NAME="M3">SYNOPSIS</A></H3>
 | |
| <B>memory </B><I>option </I>?<I>arg arg ...</I>?<BR>
 | |
| <BR>
 | |
| <H3><A NAME="M4">DESCRIPTION</A></H3>
 | |
| The <B>memory</B> 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 <B>TCL_MEM_DEBUG</B> is defined at
 | |
| compile time).
 | |
| <P>
 | |
| <DL>
 | |
| <P><DT><A NAME="M5"><B>memory info</B></A><DD>
 | |
| Produces a report containing the total allocations and frees since 
 | |
| Tcl began, the current packets allocated (the current
 | |
| number of calls to <B>ckalloc</B> not met by a corresponding call 
 | |
| to <B>ckfree</B>), the current bytes allocated, and the maximum number
 | |
| of packets and bytes allocated.
 | |
| <P><DT><A NAME="M6"><B>memory trace [on|off]</B></A><DD>
 | |
| <BR>
 | |
| Turns memory tracing on or off.  When memory tracing is on, every call
 | |
| to <B>ckalloc</B> causes a line of trace information to be written to
 | |
| <I>stderr</I>, consisting of the word <I>ckalloc</I>, 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:
 | |
| <PRE>ckalloc 40e478 98 tclProc.c 1406</PRE>
 | |
| Calls to <B>ckfree</B> are traced in the same manner.
 | |
| <P><DT><A NAME="M7"><B>memory validate [on|off]</B></A><DD>
 | |
| Turns memory validation on or off. When memory validation is enabled,
 | |
| on every call to <B>ckalloc</B> or <B>ckfree</B>, the guard zones are
 | |
| checked for every piece of memory currently in existence that was
 | |
| allocated by <B>ckalloc</B>.  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 <B>ckalloc</B> or
 | |
| <B>ckfree</B> 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.
 | |
| <P><DT><A NAME="M8"><B>memory trace_on_at_malloc</B> <I>count</I></A><DD>
 | |
| Enable memory tracing after <I>count</I> <B>ckalloc</B>'s have been performed.
 | |
| For example, if you enter <B>memory trace_on_at_malloc 100</B>,
 | |
| after the 100th call to <B>ckalloc</B>, 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.
 | |
| <P><DT><A NAME="M9"><B>memory break_on_malloc</B> <I>count</I></A><DD>
 | |
| After the <B>count</B> allocations have been performed, <B>ckalloc</B>'s
 | |
| output a message to this effect and that it is now attempting to enter
 | |
| the C debugger.  Tcl will then issue a <I>SIGINT</I> signal against itself.
 | |
| If you are running Tcl under a C debugger, it should then enter the debugger
 | |
| command mode.
 | |
| <P><DT><A NAME="M10"><B> memory display</B> <I>file</I></A><DD>
 | |
| Write a list of all currently allocated memory to the specified file.
 | |
| 
 | |
| <P></DL>
 | |
| <H3><A NAME="M11">SEE ALSO</A></H3>
 | |
| <B>ckalloc</B>, <B>ckfree</B>, <B><A HREF="../TkLib/DumpActiveMemory.htm">Tcl_ValidateAllMemory</A></B>, <B><A HREF="../TkLib/DumpActiveMemory.htm">Tcl_DumpActiveMemory</A></B>, <B>TCL_MEM_DEBUG</B>
 | |
| <H3><A NAME="M12">KEYWORDS</A></H3>
 | |
| <A href="../Keywords/M.htm#memory">memory</A>, <A href="../Keywords/D.htm#debug">debug</A>
 | |
| <HR><PRE>
 | |
| <A HREF="../copyright.htm">Copyright</A> © 1992-1999 by Karl Lehenbauer and Mark Diekhans
 | |
| <A HREF="../copyright.htm">Copyright</A> © 2000 by Scriptics Corporation.
 | |
| <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE>
 | |
| </BODY></HTML>
 | 
