< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Memory leak when running testSpeed.cxx


Hi,
 
I got the latest version of reSIProcate today and built a Win32 Release
version using VC++ 7.1.
 
I modified testSpeed.cxx slightly so i could see if there are any memory
leaks after the test finishes running. So basically I added a -  "cin >>
temp;"  statement before and after the loop that makes the calls. After
20,000 calls testServer consumed 645 MB of memory and did not free it up
even after a few minutes.
I searched the mailing list and did not find any recent references to
this problem. Am I doing something wrong ?

thanks,
anuj


**  Code from testSpeed.cxx  **

   SipStack sendStack;
   SipStack recvStack;
   sendStack.addTransport(UDP, 5070);
   recvStack.addTransport(UDP, 5080);

   NameAddr dest;
   dest.uri().scheme() = "sip";
   dest.uri().user() = "anuj_to";
   dest.uri().host() = "10.10.1.14"; //"agarwal.keencorp.keen.com";
   dest.uri().port() = 5080;
   dest.uri().param(p_transport) = "udp";
   
   NameAddr from = dest;
   from.uri().port() = 5070;
   from.uri().user() = "anuj_from";
   
   int totalCalls = 20000;

   bool done[100000];
   assert( sizeof(done)/sizeof(bool) > (unsigned int)(totalCalls+1) );
   for ( int ii=0; ii<=totalCalls; ii++ )
   {
      done[ii]=false;
   }
   
   int lastSent=0, lastRecv=0, i=0;
   
   // **** Added this line to see what the memory consumption is
initially
   cin >> temp; 

   UInt64 startTime = Timer::getTimeMs();

   while ( lastRecv < totalCalls )
   {     
      if ( (lastRecv >= lastSent) && (lastSent <= totalCalls) )
      {
         Data count( ++lastSent );
         from.uri().user() = count;
         auto_ptr<SipMessage> message(Helper::makeInvite( dest, from,
from));
         sendStack.send(*message);
      }
         
      FdSet fdset;
      sendStack.buildFdSet(fdset);
      recvStack.buildFdSet(fdset);
      int err = fdset.selectMilliSeconds(0);
      assert (err != -1);

      sendStack.process(fdset);
      recvStack.process(fdset);

      auto_ptr<SipMessage> received1(sendStack.receive());
      if (received1.get())
      {
         int user = atoi( received1->header(h_From).uri().user().c_str()
);
      
         if ( (received1->isResponse()) )
         {
            if ( received1->header(h_StatusLine).responseCode() == 200 )
            {
               if ( !done[user] )
               {
                  done[user]=true;
               
                  DeprecatedDialog dlog(from);
                  dlog.createDialogAsUAC(*received1);               
                  auto_ptr<SipMessage> ack(dlog.makeAck(*received1) );
                  auto_ptr<SipMessage> bye(dlog.makeBye());
                  sendStack.send(*ack);
                  sendStack.send(*bye);  
               }
               else
               { 
                  if ( user > lastRecv )
                  {
                     lastRecv = user;
                  }
               }
            }
         }     
      }
               
      auto_ptr<SipMessage> received2(recvStack.receive());
      if (received2.get())
      {
         MethodTypes meth =
received2->header(h_RequestLine).getMethod();

         if ( meth == INVITE )
         {
            auto_ptr<SipMessage> msg180(Helper::makeResponse(*received2,
180, dest, "Ringing"));
            recvStack.send( *msg180);
            auto_ptr<SipMessage> msg200(Helper::makeResponse(*received2,
200, dest, "OK"));
            recvStack.send(*msg200);
         }

         if ( meth == BYE )
         {
            auto_ptr<SipMessage> msg200(Helper::makeResponse(*received2,
200, dest, "OK"));
            recvStack.send(*msg200);
         }
      }
   }
  
   UInt64 elapsed = Timer::getTimeMs() - startTime;
   cout << totalCalls << " calls peformed in " << elapsed << " ms, a
rate of " 
        << totalCalls / ((float) elapsed / 1000.0) << " calls per
second.]" << endl;

   // *** At this point task manager shows 645MB consumed and it does
not go down even after a few mins
   cin >> temp;
   return 0;