[ndnSIM] High Memory Usage & Potential Memory Leaks

Christian Kreuzberger christian.kreuzberger at itec.aau.at
Wed Feb 18 01:02:31 PST 2015



using the latest version of ndnSIM and ndn-cxx, I've noticed a rather high
memory usage (several gigabytes, with

content store set to 1 packet) in simulations involving plenty of interests
and data packets. So I've compiled ndnSIM 

in debug mode and started the ndn-simple example (from scratch directory)
with valgrind active, here is the 

summary of the output.


./waf --command-template="valgrind --leak-check=full --show-reachable=yes
%s" --run ndn-simple



==9678== 1,738,712 (408 direct, 1,738,304 indirect) bytes in 3 blocks are
definitely lost in loss record 448 of 448

==9678==    at 0x4C2B0E0: operator new(unsigned long) (in

==9678==    by 0x5AD027F: ns3::Ptr<ns3::Node> ns3::CreateObject<ns3::Node>()

==9678==    by 0xD9C8CFA: ns3::NodeContainer::Create(unsigned int)

==9678==    by 0x41C856: ns3::main(int, char**) (ndn-simple.cc:63)

==9678==    by 0x41D2D7: main (ndn-simple.cc:107)


==9678== LEAK SUMMARY:

==9678==    definitely lost: 408 bytes in 3 blocks

==9678==    indirectly lost: 1,738,304 bytes in 8,257 blocks

==9678==      possibly lost: 98 bytes in 3 blocks

==9678==    still reachable: 656 bytes in 33 blocks

==9678==         suppressed: 0 bytes in 0 blocks



At first, this looks like that the memory lost is only when creating a node,
which is not good, but would be "okay" for 

simulations. But when you dig deeper into the generated output of valgrind,
you will find that the problem is caused

by several allocations about packets, regular expressions, skiplists in
content store, etc. I'm not an expert in that field, 

but I thought it is worth mentioning on the mailing list.

Example of the most important ones:


==9806== 238,400 bytes in 200 blocks are indirectly lost in loss record 447
of 448

==9806==    at 0x4C2B0E0: operator new(unsigned long) (in

==9806==    by 0x8DE20A2:
std::allocator<ndn::Data>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned
long, void const*) (new_allocator.h:104)

==9806==    by 0x8DE1D3D:
std::allocator<ndn::Data>, (__gnu_cxx::_Lock_policy)2> >
std::allocator<ndn::Data>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long)

==9806==    by 0x8DE18E7:
std::allocator<ndn::Data>>(std::_Sp_make_shared_tag, ndn::Data*,
std::allocator<ndn::Data> const&) (shared_ptr_base.h:499)

==9806==    by 0x8DE138D: std::__shared_ptr<ndn::Data,
p_make_shared_tag, std::allocator<ndn::Data> const&) (shared_ptr_base.h:957)

==9806==    by 0x8DE0B6B:
ake_shared_tag, std::allocator<ndn::Data> const&) (shared_ptr.h:316)

==9806==    by 0x8DDFC5B: std::shared_ptr<ndn::Data>
std::allocator<ndn::Data>>(std::allocator<ndn::Data> const&)

==9806==    by 0x8DDF103: std::shared_ptr<ndn::Data>
std::make_shared<ndn::Data>() (shared_ptr.h:614)

==9806==    by 0x8FD6B9C:

==9806==    by 0xD912BAA: ns3::Packet::RemoveHeader(ns3::Header&)

==9806==    by 0x8FF2F53: std::shared_ptr<ndn::Data const>

==9806==    by 0x8FF18DD:
ns3::Ptr<ns3::Packet const>, unsigned short, ns3::Address const&,
ns3::Address const&, ns3::NetDevice::PacketType)



==9806== 216,879 bytes in 201 blocks are indirectly lost in loss record 446
of 448

==9806==    at 0x4C2B800: operator new[](unsigned long) (in

==9806==    by 0xD8E7074: ns3::Buffer::Allocate(unsigned int)

==9806==    by 0xD8E6D93: ns3::Buffer::Create(unsigned int) (buffer.cc:141)

==9806==    by 0xD8E8666: ns3::Buffer::AddAtStart(unsigned int)

==9806==    by 0xD912A53: ns3::Packet::AddHeader(ns3::Header const&)

==9806==    by 0xAD8A64A:
ns3::PointToPointNetDevice::AddHeader(ns3::Ptr<ns3::Packet>, unsigned short)

==9806==    by 0xAD8E466:
ns3::PointToPointNetDevice::Send(ns3::Ptr<ns3::Packet>, ns3::Address const&,
unsigned short) (point-to-point-net-device.cc:502)

==9806==    by 0x8FF10E5:

==9806==    by 0x8FF150C: ns3::ndn::NetDeviceFace::sendData(ndn::Data
const&) (ndn-net-device-face.cpp:111)

==9806==    by 0x8DF6F06: nfd::Forwarder::onOutgoingData(ndn::Data const&,
nfd::Face&) (forwarder.cpp:377)

==9806==    by 0x8DF6455: nfd::Forwarder::onIncomingData(nfd::Face&,
ndn::Data const&) (forwarder.cpp:333)

==9806==    by 0x8DEDA96: nfd::Forwarder::onData(nfd::Face&, ndn::Data
const&) (forwarder.hpp:263)



The valgrind output is rather long, I suggest you try generating it by
yourself. I'm using Ubuntu 14.04, if that matters. 

I'm not after chasing every single memory leak, though if it involves
packets/packet based structures, there might be

an issue with ndnSIM or even NFD, that could affect the testbed aswell.


In addition, I've tested ndn-simple with Frequency set to other values
instead of 10, here is the resulting output:



I don't think that roughly 1.6 MegaBytes of memory lost is a big deal,
though given the size of the simulation and

the number of interests transmitted, it might become a problem with larger
simulations. I'm also not sure if this

memory leaks is a result from lost packets or interests that were sent
during the last millisecond of the simulation.


Anyway, I hope this post helps to find and reduce some memory leaks.


Best regards,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20150218/8aa4a6d3/attachment.html>

More information about the ndnSIM mailing list