2009年2月3日星期二

Enable DMalloc support for NS2

Since my NS2 eats too much memory, which makes the simulation not scalable, I was trying to profile the memory usage by enable dmalloc support for NS2.

Originally I download ns-2.33-all-in-one and install it on my Ubuntu 8.04 Linux.

The NS2 manual seems to show that it very easy to enable dmalloc for NS2, but it's kinda out of date.

First, ns2 needs an old version of dmalloc, for example, I use dmalloc-4.8.2. If u use dmalloc-5.5.1, compiler will complain "_malloc_leap was not declared in this scope"

Extract and drop dmalloc-4.8.2 in the parallel directory of ns-2.33, build it using "./configure" and "make". "make install" is unneccessary. If you use "make install" to install dmalloc in your system, the configure script of ns-2.33 will complain "checking for return.h... no".

Change working directory to ns-2.33, type " ./configure --with-otcl=../otcl-1.13 --with-tclcl=../tclcl-1.19 --with-dmalloc=../dmalloc-4.8.2", it will generate Makefile for you.

Try "make" in ns-2.33, a link error occur: multiple definition of TclpAlloc. This is because libtcl8.4.a already defines TclpAlloc and ns-2.33/lib/dmalloc_support.cc tries to redefine it. I actually have no idea of how to solve this problem. A temporary solution is, if u do not care about the memory TclpAlloc and Tcl_Alloc, just comments out the definition of these two funtions in dmalloc_support.cc and then compilation will success.

After building ns2 with dmalloc, then u can follow the steps in ns2 manual except for the one adding alias for bash. It seems to be a typing error in my ns2 manual. The correct alias should be: function dmalloc { eval `command dmalloc -b $*`; }

That's all.


没有评论: