cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1416
Views
0
Helpful
5
Replies

CTIOS API creating memory leak

akeel.rehman
Level 1
Level 1

Hi,

I have developed a simple CTIOS monitor application which just catches the OnCallDelivered and OnCallEstablished events and prints some log on console. But when i run this application, it eats up all the JVM memory. I have also tried it running with the options -Xmn100M -Xms500M -Xmx500M but no difference, increasing JVM memory just delays the OutOfMemory exception error. I have analyzed my applicaiton with JConsole and found that memory is not being released by the GC and used memory is increasing continuously (which ultimately results in out of memory exception error). We are using CTIOS Server version 7.5 in our contact center. Following is my code:

public class Driver implements IGenericEvents, CtiOs_Enums.EventID {


    CtiOsSession vCtiOsSession;
   
    public static void main(String[] args) {
        new Driver();
    }
   
    public Driver() {
        boolean error=false;
        tg = new ThreadGroup("AnserMachine threads group");
       
        Properties p = new Properties();
         try {
            p.load(new FileInputStream("config.ini"));
        } catch (FileNotFoundException e) {
            System.out.println("Configuration file 'config.ini' NOT FOUND ...\n");
            error=true;
        } catch (IOException e) {
            System.out.println("ERROR in READING configuration file 'config.ini' ...\n");
            error=true;
        }
       
        if(!error) {
           
            // Check if connection parameters are there in configuration file
            if(p.getProperty("CTIOSA")==null || p.getProperty("CTIOSB")==null ||
               p.getProperty("PORTA")==null || p.getProperty("PORTB")==null) {
               
                System.out.println("Error encountered, Configurations missing. Try again later !");
                System.exit(0);
            }
           
            // Connect to CTIOS Server
            vCtiOsSession = new CtiOsSession();
            vCtiOsSession.AddEventListener(this, CtiOs_Enums.SubscriberList.eAllInOneList);
           
            Arguments args = new Arguments();
            args.SetValue(CtiOs_IKeywordIDs.CTIOS_CTIOSA, p.getProperty("CTIOSA"));
            args.SetValue(CtiOs_IKeywordIDs.CTIOS_PORTA, p.getProperty("PORTA"));
            args.SetValue(CtiOs_IKeywordIDs.CTIOS_CTIOSB, p.getProperty("CTIOSB"));
            args.SetValue(CtiOs_IKeywordIDs.CTIOS_PORTB, p.getProperty("PORTB"));
            args.SetValue(CtiOs_IKeywordIDs.CTIOS_HEARTBEAT, 60);
            pauseTime = p.getProperty("PAUSE");
           
            int connectionStatus = vCtiOsSession.Connect(args);
           
            // Check if connection established
            if(connectionStatus==1) {
                System.out.println("Connecting to Server ...");
            }
            else {
                System.out.println("Application Failed, Verify connection settings and try again !");
                System.exit(0);
            }           
        }
        else {
            System.out.println("Error encountered, quiting application. Try again later !");
        }
    }

    public void OnEvent(int eventId, Arguments args) {
      
        switch(eventId) {
            case eOnConnection:
                OnConnection(args);
                break;
            case eOnConnectionClosed:
                OnConnectionClosed(args);
                break;
            case eOnConnectionFailure:
                OnConnectionFailure(args);
                break;
            case eCTIOSFailureEvent:
                OnCtiosFailure(args);
                break;
            case eCallDeliveredEvent:
                OnCallDelivered(args);
                break;
            case eCallEstablishedEvent:
                OnCallEstablished(args);
                break;
            case eAnswerCallRequest:
                OnCallEstablished(args);
                break;
        }
    }
   
    public void OnCallEstablished(Arguments eventArgs) {
        String uniqueObjId = eventArgs.GetValue(CtiOs_IKeywordIDs.CTIOS_UNIQUEOBJECTID)+"";
        String extNum = uniqueObjId.substring(uniqueObjId.lastIndexOf('.')+1, uniqueObjId.length());
       
        System.out.println("Call ANSWERED at: "+extNum);      
    }
   
    public void OnCallDelivered(Arguments eventArgs) {
        String uniqueObjId = eventArgs.GetValue(CtiOs_IKeywordIDs.CTIOS_UNIQUEOBJECTID)+"";
        String extNum = uniqueObjId.substring(uniqueObjId.lastIndexOf('.')+1, uniqueObjId.length());


        if(Call.eCallConnectionAlerting==Integer.parseInt(eventArgs.GetValue(CtiOs_IKeywordIDs.CTIOS_CALLSTATUS)+"")) {
                       
                System.out.println("Call Ringing at: "+extNum);          
        }
    }
   
    public void OnConnection(Arguments eventArgs) {   
       
        Arguments args = new Arguments();
        String filter = "messageid=" + CtiOs_Enums.EventID.eCallDeliveredEvent+
                        ","+ CtiOs_Enums.EventID.eCallEstablishedEvent;
       
        args.SetValue(CtiOs_IKeywordIDs.CTIOS_FILTER, filter);
        int returnValue = vCtiOsSession.SetMessageFilter(args);
               
        System.out.println("Application Started ..., [Filter Status:"+returnValue+"] ...");
    }

    public void OnConnectionClosed(Arguments eventArgs) {
        System.out.println("DEBUG: Connection has been CLOSED ...");
    }
   
    public void OnConnectionFailure(Arguments eventArgs) {
        System.out.println("DEBUG: Connection has been FAILED ...");
    }

    public void OnCtiosFailure(Arguments eventArgs) {
        System.out.println("Ctios has been FAILED ...");
    }
}

I have also tried to dump the heap using

jmap -dump:format=b,file=c:/tmp/heap.bin 75828

and then visualized this heap dump using

jhat -J-Xmx326m c:/tmp/heap.bin

Which clearly indicated that Instances of some of the CIL objects in memmory are continuously increasing. Following is part of the dum that shows this:

DUMP 1

67379 instances of class com.cisco.cti.ctios.cil.Arg
5800 instances of class com.cisco.cti.ctios.cil.Arguments
1810 instances of class com.cisco.cti.ctios.cil.CilRefArg
1808 instances of class com.cisco.cti.ctios.cil.Call
759 instances of class com.cisco.cti.ctios.util.CtiOs_KeyInfo
419 instances of class com.cisco.cti.ctios.util.LogEvent
258 instances of class com.cisco.cti.ctios.cil.CilPacket
257 instances of class com.cisco.cti.ctios.cil.ServiceMessage
257 instances of class com.cisco.cti.ctios.util.Serialize
13 instances of class com.cisco.cti.ctios.util.UnNamedEvent
4 instances of class com.cisco.cti.ctios.cil.CilObjectFactoryArg

DUMP 2

77684 instances of class com.cisco.cti.ctios.cil.Arg
6676 instances of class com.cisco.cti.ctios.cil.Arguments
2202 instances of class com.cisco.cti.ctios.cil.CilRefArg
2200 instances of class com.cisco.cti.ctios.cil.Call
759 instances of class com.cisco.cti.ctios.util.CtiOs_KeyInfo
54 instances of class com.cisco.cti.ctios.util.LogEvent
45 instances of class com.cisco.cti.ctios.cil.ServiceMessage
36 instances of class com.cisco.cti.ctios.cil.CilPacket
35 instances of class com.cisco.cti.ctios.util.Serialize
13 instances of class com.cisco.cti.ctios.util.UnNamedEvent
4 instances of class com.cisco.cti.ctios.cil.CilObjectFactoryArg


DUMP 3

92086 instances of class com.cisco.cti.ctios.cil.Arg
7918 instances of class com.cisco.cti.ctios.cil.Arguments
2572 instances of class com.cisco.cti.ctios.cil.CilRefArg
2570 instances of class com.cisco.cti.ctios.cil.Call
759 instances of class com.cisco.cti.ctios.util.CtiOs_KeyInfo
225 instances of class com.cisco.cti.ctios.util.LogEvent
140 instances of class com.cisco.cti.ctios.cil.CilPacket
139 instances of class com.cisco.cti.ctios.cil.ServiceMessage
139 instances of class com.cisco.cti.ctios.util.Serialize
13 instances of class com.cisco.cti.ctios.util.UnNamedEvent
4 instances of class com.cisco.cti.ctios.cil.CilObjectFactoryArg

Any idea, what i am doing wrong? How can i prevent out of memory exception error. Please help me.

Regards,

Akeel

5 Replies 5

Make sure you have the latest patch for CTIOS, if that doesn't solve your problem, you're better off opening a TAC case.

david

dehebert
Cisco Employee
Cisco Employee

Hello Akeel,

Are you seeing the application having a memory leak or the actual CTIOS Process?

What exact version of CTIOS are you running including SR and ES?

Thanks,
Denis

Thanks Dvaid, Denis for the response.

I have checked with the IPCC team and we have CTIOS 7.5(8) installed.

Are you seeing the application having a memory leak or the actual CTIOS Process?

Since some of the objects (that are created by CTIOS) like

com.cisco.cti.ctios.cil.Arg,

com.cisco.cti.ctios.cil.Arguments,

com.cisco.cti.ctios.cil.Call

etc. are never disposed of from memory, number of instances for these objects keeps on increasing which finally results in out of memory exception error ... that's why i believe that this is a memory leak on which we have no control.

Is there some patch we need to install? Any hint would help a lot.

Hello Akeel,

I checked the CTIOS 7.5(9) release notes to see if there were any defects resolved in this version that may be coming into play here.

I only see one defect re;ated to memory and it is this one:

CSCtf24040:  CTIOS Server does not release all memory after agent logs out.

The release notes are here:

http://www.cisco.com/web/software/280840587/35370/Release_Notes_for_CTIOS_7.5.9.pdf

I would recommend upgrading to 7.5(9) and see if this resolves the issue or not.

I also checked for any updates on top of 7.5(9) and there is nothing related to memory.

There are also 12 other defects resolved in this version.

I hope this helps.

Thank you,
Denis

Thanks Denis, i will ask IPCC team to upgrade CTIOS to the version 7.5(9), and hope that this will solve the problem.

Thanks again, this definitely does help.