[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] (slightly) better dmalloc MFP



John, et. al.:

Please find attached a (slightly) better interface for to dmalloc. This
patch applies cleanly to UNMODIFIED ns-2.1b7 source code. The principal
benefit of this patch is the display of file and line number information
in the dmalloc log. 'dmalloc-summarize' is completely superfluous and
unneccesary, since the user can simply look at the dmalloc log file to
see what hasn't been freed.

Note that code that doesnt use dmalloc, such as Tcl and OTCL, will still
have 'ra=.....' lines. However, it's not difficult to hack the packages
to use dmalloc (left as an exercise, this is why its called 'hacking' :-)

This is a relatively clever redefinition of the placement new operator
to include the file and line numbner information. In the patch, "new" has
been replaced by "_NEW", which DTRT depending on whether or not dmalloc
has been enabled by configure. IT IS NOT POSSIBLE TO REDEFINE the 'new'
operator using a macro, because STL does creative things with the placement
new operator that conflict with this dmalloc hack.

Users should replace their calls to 'new' with '_NEW' so that their
code will show up with file/line infomration when they use dmalloc or
attempt to do memory leak tracing with dmalloc.

Hope this is useful to some/all of the ns community.


-scooter

BTW: The patch has been compressed using gzip, just in case there are
some less experienced users out there.

dmalloc.patch.gz