12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

24.4.2 Memory Co<strong>ns</strong>erv<strong>at</strong>ion TipsSome tips to saving memory (some of these use examples from the cmcast-100.tcl script): If you have many links or nodes:Avoid trace-all: $<strong>ns</strong> trace-all $f causes trace objects to be pushed on all links. If you only want to trace onelink, there’s no need for this overhead. Saving is about 14 KB/link.Use arrays for sequences of variables : Each variable, say n$i in set n$i [$<strong>ns</strong> node], has a certain overhead. If asequence of nodes are cre<strong>at</strong>ed as an array, i.e. n($i), then only one variable is cre<strong>at</strong>ed, co<strong>ns</strong>uming much less memory.Saving is about 40+ Byte/variable.Avoid unnecessary variables : If an object will not be referred to l<strong>at</strong>er on, avoid naming the object. E.g. set cmcast(1)[new CtrMcast $<strong>ns</strong> $n(1) $ctrmcastcomp [list 1 1]] would be better if replaced by new CtrMcast$<strong>ns</strong> $n(1) $ctrmcastcomp [list 1 1]. Saving is about 80 Byte/variable.Run on top of FreeBSD : malloc() overhead on FreeBSD is less than on some other systems. We will eventually port th<strong>at</strong>alloc<strong>at</strong>or to other pl<strong>at</strong>ofrms.Dynamic binding : Using bind() in C++ co<strong>ns</strong>umes memory for each object you cre<strong>at</strong>e. This approach can be very expe<strong>ns</strong>iveif you cre<strong>at</strong>e many identical objects. Changing bind() to delay_bind() changes this memory requirement toper-class. See <strong>ns</strong>/object.cc for an example of how to do binding, either way.Disabling packet headers : For packet-inte<strong>ns</strong>ive simul<strong>at</strong>io<strong>ns</strong>, disabling all packet headers th<strong>at</strong> you will not use in yoursimul<strong>at</strong>ion may significantly reduce memory usage. See Section 12.1 for detail.24.4.3 Some st<strong>at</strong>istics collected by dmallocA memory co<strong>ns</strong>umption problem occured in recent simul<strong>at</strong>io<strong>ns</strong> (cmcast-[150,200,250].tcl), so we decided to take a closerlook <strong>at</strong> scaling issue. See page http://www-mash.cs.berkeley.edu/<strong>ns</strong>/<strong>ns</strong>-scaling.html which demostr<strong>at</strong>es the efforts in findingthe bottlneck.<strong>The</strong> following table summarises the results of investig<strong>at</strong>ing the bottleneck:KBytes cmcast-50.tcl(217 Links) cmcast-100.tcl(950 Links)trace-all 8,084 28,541turn off trace-all 5,095 15,465use array 5,091 15,459remove unnecessay variables 5,087 15,451on SunOS 5,105 15,48424.5 Memory LeaksThis section deals with memory leak problems in <strong>ns</strong>, both in Tcl as well as C/C++.218

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!