When I use the Sip Sorcery' SIP Components to make simple point 2 point call / answer just like softphone done, the used memory increased when more call made and without decrease even after call GC.Collection. So please point me what's the problem.
Let me explain about the code:
1. I used configuration file to tell what's the two points so that they can connect each other, something like following:
Code: Select all
<appSettings>
<add key="Local" value="127.0.0.1:5060"/>
<add key="Remote" value="127.0.0.1:6060"/>
</appSettings>
2. Prepare the local SIP Transport as following:
Code: Select all
private void InitialiseSIP()
{
// Configure the SIP transport layer.
m_sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine());
m_sipTransport.AddSIPChannel(new SIPUDPChannel(m_sipEp));
m_sipTransport.SIPTransportRequestReceived += SIPTransportRequestReceived;
IsReady = true;
}
3. The SIPTransportRequestReceived used to process coming SIP request, the code for INVITE is as following:
Code: Select all
// Send Trying when get INVITE to prevent dup coming INVITE
SIPResponse res = SIPTransport.GetResponse(sipRequest, SIPResponseStatusCodesEnum.Trying, null);
Transport.SendResponse(res);
Thread.Sleep(200);
res = SIPTransport.GetResponse(sipRequest, SIPResponseStatusCodesEnum.Ringing, null);
Transport.SendResponse(res);
Thread.Sleep(10);
UASInviteTransaction uasTransaction = Transport.CreateUASTransaction(sipRequest, remoteEndPoint, localSIPEndPoint, null);
SIPServerUserAgent uas = new SIPServerUserAgent(Transport, null, null, null, SIPCallDirection.In, null, null, LogTraceMessage, uasTransaction);
uas.CallCancelled += UASCallCancelled;
string toTag = CallProperties.CreateNewTag();
string sdp = CreateSDP(m_sipEp.Address.ToString()).ToString();
Thread.Sleep(300);
uas.Answer("application/sdp", sdp, toTag, null, SIPDialogueTransferModesEnum.NotAllowed);
Thread.Sleep(15000);
uas.SIPDialogue.Hangup(m_sipTransport, null);
4 The INVITE coming from call as following:
Code: Select all
SIPEndPoint proxyEP = new SIPEndPoint(mRemote);
SIPClientUserAgent uac = new SIPClientUserAgent(m_sipTransport, proxyEP, null, null, LogTraceMessage);
uac.CallTrying += CallTrying;
uac.CallRinging += CallRinging;
uac.CallAnswered += CallAnswered;
uac.CallFailed += CallFailed;
SIPCallDescriptor callDescriptor = GetCallDescriptor(info, m_sipEp);
uac.Call(callDescriptor);
5. As the response to the BYE request, the 200 OK is sent.
6. For testing, a loop is used to make calls.
For detail please see full code in attachment files - it's the sip wrapper coming from my working project - a console project which can server as both the sip server and sip client. You can copy the build result to another place and modify the configuration file so that two instances can run as a pair, start one as server, start another one as client with an argument as the testing call time such as "siptest 10". Use the Task manage to watch usage of memory, after the sip port is ready, under client one's console input 'r' and enter to start the call testing, you can find that the memory used by both items are increased when process call. Under console input 'END' and enter to end the SIP - GC.Collection is called after that, you can find the number of Handle of both instances decrease in task manage.
Anyone can point me where the problem and how can I make the used memory decrease.
Thanks in advance!
Henry