RE: [reSIProcate] Memory leak when running testSpeed.cxx
Thanks for the tip. Yes, if i make the suggested change, then i see the
free memory climb back up and come back to what it was before the test
within a minute or so.
andy
-----Original Message-----
From: Scott Godin [mailto:slgodin@xxxxxxxxxxxx]
Sent: Wednesday, March 23, 2005 2:43 PM
To: Andy Agarwal; resiprocate-devel@xxxxxxxxxxxxxxxxxxx
Subject: RE: [reSIProcate] Memory leak when running testSpeed.cxx
"After 20,000 calls testServer consumed 645 MB of memory and did not
free it up even after a few minutes."
When testSpeed is waiting in the cin >> temp call it is not calling
process on the stack. Thus any outstanding timers will not actually be
cleaned up.
Try modifying to stay in a process loop on both the send and recv stacks
for a few minutes - instead of waiting in a cin >> temp call.
Also - in windows - you can also use the LEAK_CHECK define and run in
the Debugger. Check out WinLeakCheck.hxx to see usage. That would help
track down where a leak is - if there is still one.
Scott
-----Original Message-----
From: Andy Agarwal [mailto:Andy@xxxxxxxxxxx]
Sent: Wednesday, March 23, 2005 4:45 PM
To: resiprocate-devel@xxxxxxxxxxxxxxxxxxx
Subject: [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;
_______________________________________________
resiprocate-devel mailing list
resiprocate-devel@xxxxxxxxxxxxxxxxxxx
https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel