📄 node241.html
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><!--Converted with jLaTeX2HTML 2002 (1.62) JA patch-1.4patched version by: Kenshi Muto, Debian Project.LaTeX2HTML 2002 (1.62),original version by: Nikos Drakos, CBLU, University of Leeds* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>21.4.1 Using dmalloc</TITLE><META NAME="description" CONTENT="21.4.1 Using dmalloc"><META NAME="keywords" CONTENT="everything"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META NAME="Generator" CONTENT="jLaTeX2HTML v2002 JA patch-1.4"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="everything.css" tppabs="http://www.isi.edu/nsnam/ns/doc/everything.css"><LINK REL="next" HREF="node242.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node242.html"><LINK REL="previous" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html"><LINK REL="up" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html"><LINK REL="next" HREF="node242.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node242.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html5004" HREF="node242.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node242.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html4998" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html4992" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html5000" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html5002" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html5005" HREF="node242.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node242.html">21.4.2 Memory Conservation Tips</A><B> Up:</B> <A NAME="tex2html4999" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html">21.4 Memory Debugging</A><B> Previous:</B> <A NAME="tex2html4993" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html">21.4 Memory Debugging</A>   <B> <A NAME="tex2html5001" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html5003" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <BR><BR><!--End of Navigation Panel--><H2><A NAME="SECTION04141000000000000000"></A><A NAME="sec:usedmalloc"></A><BR>21.4.1 Using dmalloc</H2><P>In order to use dmalloc do the following:<UL><LI>Define an alias <PRE>for csh: alias dmalloc 'eval `\dmalloc -C \!*`', for bash: function dmalloc { eval `command dmalloc -b $*` }%$</PRE></LI><LI>Next turn debugging on by typing <TT>dmalloc -l logfile low </TT></LI><LI>Run your program (which was configured and built with dmalloc asdescribed above). </LI><LI>Interpret logfile by running <TT>dmalloc_summarize ns logfile</TT>.(You need to download <TT>dmalloc_summarize</TT> separately.) </LI></UL><P>On some platforms you may need to link things statically to get dmalloc towork. On Solaris this is done by linking with these options:<TT>"-Xlinker -B -Xlinker -static libraries -Xlinker -B -Xlinker -dynamic -ldl -lX11 -lXext"</TT>.(You'll need to change Makefile. Thanks toHaobo Yu and Doug Smith for working this out.) <P>We can interpret a sample summary produced from this process onns-2/tcl/ex/newmcast/cmcast-100.tcl with an exit statement after the200'th duplex-link-of-interefaces statement: <P>Ns allocates 6MB of memory. <BR> 1MB is due to TclObject::bind <BR> 900KB is StringCreate, all in 32-byte chunks <BR> 700KB is NewVar, mostly in 24-byte chunks <BR>Dmalloc_summarize must map function names to and from their addresses. Itoften can't resolve addresses for shared libraries, so if you see lots ofmemory allocated by things beginning with ``ra='', that's what it is. Thebest way to avoid this problem is to build ns statically (if not all, thenas much as possible). <P>Dmalloc's memory allocation scheme is somewhat expensive, plus there'sbookkeeping costs. Programs linked against dmalloc will consume morememory than against most standard mallocs. <P>Dmalloc can also diagnose other memory errors (duplicate frees, bufferoverruns, etc.). See its documentation for details. <P><HR><!--Navigation Panel--><A NAME="tex2html5004" HREF="node242.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node242.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html4998" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html4992" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html5000" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html5002" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html5005" HREF="node242.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node242.html">21.4.2 Memory Conservation Tips</A><B> Up:</B> <A NAME="tex2html4999" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html">21.4 Memory Debugging</A><B> Previous:</B> <A NAME="tex2html4993" HREF="node240.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node240.html">21.4 Memory Debugging</A>   <B> <A NAME="tex2html5001" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html5003" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <!--End of Navigation Panel--><ADDRESS>2003-09-23</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -