« Back to CTIOS Toolkit Questions

RE: Memory leaks in CTIOS

Combination View Flat View Tree View
Threads [ Previous | Next ]
Showing 1 - 20 of 28 results.
of 2
Hi,
 
In CTIOS when I am using DumpArgs() to print the arguments structure in the taskbar it is showing too may handles. Some times it is showing 1 billion also. If I commented the use of that function then in taskbar it is showing 200 to 300 handles. Is there any function shall I call to release the memory for Arguments structure after the DumpArgs().
 
Thanks,
Sunitha.

Which Cil and version are you using? A memory leak was found in
getElement which is used by most functions. This was found in 7.2(3)
and fixed in 7.5(2) and 7.2(6) . Use the latest CTIOS Client toolkit
version and demonstrate the issue with one of the sample applications
with the Cil you are using. If problem persists, open a Service Request
using your Developer Services contract subscription and provide the
modified sample so that our engineers can duplicate your specific issue.

I have to make a good case and present hard evidence that the upgrade to the latest CTIOS would fix the memory leak we are having. When you say that leaky getElement is used by MOST functions, do you know if it's used by .CreateInstance(), .GetValueArray() or .GetValueInt() in particular and by C++Phone sample app in general? I couldn't find any direct calls to getElement in C++Phone, but as you said, it could be called by other functions.
Thanks.

I believe all GetValue methods utilize the GetElement method.

David:  I upgraded 7.5(1) with maintenence release 7.5(10).  Now, when I compile the C++ Phone sample, it complains of missing CTIOSKeyStrings.h and CTIOSKeyStringsAbbrev.h.  Do you know if I need to take a certain upgrade path?  Thanks.

The C++ sample has not changed. Are you pointing to the Include directory for the Win32 Cil? Are the CTIOSKeyStrings.h and CTIOSKeyStringsAbbrev.h. files in the include directory?

It is pointing to the include directory.  However, I do not see the two .h files in the C:\Program Files\Cisco Systems\CTIOS Client\CTIOS Toolkit\Win32 CIL\Include directory.  I’m wondering if they were included in a different maintenance release that I need to apply first.

The 7.5(10) maint release should contain all the files you need to upgrade from 7.5(1).
I suggest you open a Service Request (specify Other for Technology and CDN Contact Center Applications for SubTechnology. I can then send you the include files to see if it resolves your issue.

David:  Thank you for the offer.  I may take you up on the offer if I can't figure it out.  So far, I have reverted back to 7.5(1) and upgraded to 7.5(2) and compiling succeeded.
I am trying to track down a memory leak with Arthur.  After the ref counts have decremented to zero what is performing the actual clean-up?  Do you know if there is a way to force the clean-up or if there is a threshold in general?  I'm trying to confirm if there is still a memory leak, because I still see the memory footprint increasing in 7.5(2).

I suggest you install v8.5(3) I have confirmed you can build the C++ Phone with that version and also it includes the fix to the memory leak that was found in 7.5(1). I could not see any memory growing in the C++ sample with 8.5(3).

There is no way to force clean-up and there is no threshold. Memory should be released when the reference count goes to 0.

Do you see a memory leak with C++ Phone with 7.5(2) or just with your modified sample that uses statistics?

Note that the sample is provided as is and is not intended for production use.

If we install 8.5(3), does the server also need to be on 8.5?
Is there a way to dump all the ref counts ?
I believe the memory leak started with the modified version to obtain statistics.

The server also needs to be at 8.5. I suggest you review your statistics code for memory leaks. I have verified that the COM Cil application ctiosphone does not have any memory leak when skillgroupstatistics are enabled. Note that the COM Cil uses the C++ Cil so if there was a memory leak it would show up in a COM Cil app. Is it possible for you to use the COM CIL rather than the C++ CIL? That way you do not have to worry about memory management.

David,
Whe you say to review our statistics code for memory leask, this would be very simple, because there are only few lines of code I added to the C++Phone sample app. Here they are:
In the EvenSink.cpp, in the OnSetAgentModeEvent, where it sets agentID, password, instrument and peripheralID before doing the actual login, I added 3 lines to enable remote login:
arLoginReq.AddItem(CTIOS_REMOTELOGIN, "true");
arLoginReq.AddItem(CTIOS_AGENTREMOTENUMBER, "1234567890");
arLoginReq.AddItem(CTIOS_AGENTCALLMODE, 3);
then it does m_pCtiAgent->Login(arLoginReq); and arLoginReq.Release(); I didn't touch these lines.
Then in OnQueryAgentStateConf, I added a call to enable stats:
Arguments &skillGrpParam = Arguments::CreateInstance();
rc = m_pCtiAgent->EnableSkillGroupStatistics(skillGrpParam);
unsigned long rcode = skillGrpParam.Release();   //and when I print rcode, it's 0, so all is good.
And then I add OnSkillGroupStatisticsUpdated event with no code in it.
When I execute with the above code, there is no memory leak, memory usage doesn't increase.
The memory leak starts when in OnSkillGroupStatisticsUpdated, I add the following:
Arguments &stats = Arguments::CreateInstance();
stats = rArguments.GetValueArray("Statistics");
unsigned long rcode = stats.Release(); //rcode here returns 2; even when I call .Release() twice so it rcode does become 0, the next time the event is called I get rcode of 2 again. And the memory usage keeps increasing.
So as you can see, there is very little code I added, and the leak seem to start only after the last two .CreateInstance and .GetValueArray. So where am I doing something wrong? I am using the methods that are part of the SDK.
Thanks.
p.s. Do you have the actual COM code that you used to get stats? Is my C++ equivalent is similar to your COM, or am I missing something. Could you send me the lines you added in COM... if you can?
Thanks.
 

David,
One more thing I forgot to mention. I tried the above code in v7.5(2) going upto and including v7.5(6) and it still leaks.

Here is the VB.NET (COM Cil) Code

Private Sub m_session_OnSkillGroupStatisticsUpdated(ByVal pIArguments As Cisco.CTIOSCLIENTLib.Arguments) Handles m_session.OnSkillGroupStatisticsUpdated
Dim statArgs As New Cisco.CTIOSCLIENTLib.Arguments
Dim numAgents As Integer
Dim strAgents As String

LogEvent("OnSkillGroupStatisticsUpdated", pIArguments)
' Log("Stats: " + pIArguments.GetValue("Statistics").DumpArg())
statArgs = pIArguments.GetValueArray("Statistics")
' Log("Statargs:" + statArgs.DumpArgs())
If statArgs.IsValid("AgentsLoggedOn") Then
' Log("Valid")
Else
' Log("NotValid")
End If
Log("numAgents: " + Str(statArgs.GetValueInt("AgentsLoggedOn")))
numAgents = statArgs.GetValueInt("AgentsLoggedOn")
Log("numAgents: " + Str(numAgents))

End Sub


Private Sub Enable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enable.Click
Dim myskillArgs, skillArgs As New Cisco.CTIOSCLIENTLib.Arguments

Log("Sending EnableSkillGroupStatistics")
skillArgs.AddItem("1", 1) ' 1 is skillgroupnumber
skillArgs.AddItem("2", 0) ' 0 is skillgroup priority
skillArgs.AddItem("3", 2) ' 2 is skillgroupnumber
skillArgs.AddItem("4", 0) ' 0 is skillgroup priority
myskillArgs.AddItem("SkillGroupNumbers", skillArgs)
m_Agent.EnableSkillGroupStatistics(myskillArgs)

End Sub

Private Sub Disable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Disable.Click
Dim myskillArgs, skillArgs As New Cisco.CTIOSCLIENTLib.Arguments
skillArgs.AddItem("1", 1) ' 1 is skillgroupnumber
skillArgs.AddItem("2", 0) ' 0 is skillgroup priority
skillArgs.AddItem("3", 2) ' 2 is skillgroupnumber
skillArgs.AddItem("4", 0) ' 0 is skillgroup priority
myskillArgs.AddItem("SkillGroupNumbers", skillArgs)
m_Agent.DisableSkillGroupStatistics(myskillArgs)
End Sub

But in Agent Desktop, if I want to monitor stats for ALL skillgroups, I don't have to specify the skillgroups, do I ? Therefore you can omit your .AddItem calls. Am I right?
Another questions. If my app runs continuously, 24 hours a day, I call EnableSkillGroupStatistics once and I do NOT have to call DisableSkillGroupStatistics. Am I correct?

Correct, if you want all skill groups you do not specify any skills arguments to the EnableSkillGroupStatistics method.
Correct, you only have to enable skillgroupstatistics once.

David,
I reviewed your code above and it looks like I am using the same logic in C++. The only difference is that I don't call DisableSkillGroupStatistics and I don't set skillGroups when calling EnableSkillGroupStatistics. What I noticed in your code is that you set skillGroups using AddItem for skillArgs, then you call myskillArgs.AddItem("SkillGroupNumbers", skillArgs) and you use myskillArgs to EnableSkillGroupStatistics. The Java code example in the documentation uses SetValue to set skillGroups and corresponding peripheralID instead of AddItem and it does NOT use a line similar to your myskillArgs.AddItem("SkillGroupNumbers", skillArgs). Is that right? I am doing anything of that kind because I need stats for ALL groups, so I just call:
Arguments &skillGrpParam = Arguments::CreateInstance();
rc = m_pCtiAgent->EnableSkillGroupStatistics(skillGrpParam);
but maybe I do need to set something like your myskillArgs.AddItem("SkillGroupNumbers", skillArgs) where skillArgs would be an empty object? What do you think?
thanks.

Correction,
When in the above I say, "I am doing anything of that kind because I need stats for ALL groups", I really mean "I am NOT doing anything of that kind because I need stats for ALL groups"

You are receiving the skillgroupstatistics for all stats, correct? My example was for obtaining only specific skills. You are correct for all skills you send an empty skillGrpParam, just make sure you release it after you call EnableSkillGroupStatistics.

Showing 1 - 20 of 28 results.
of 2
David Lender (474)
Shannon McCoy (91)
Arthur Shats (57)
Christopher Nagel (47)
GEOFFREY THOMPSON (40)