Skip to content

Thread, Memory & CPU leak using mobicents RTP #21

@mcacker

Description

@mcacker

Hi,

i'm using mobicents RTP to implements a media server and SBC monitor, by setting up a call and sending and receiving RTP. Unfortunately, whenever the call is stopped and restarted there is a Thread leak, memory leak and slowly increasing CPU usage, to the point that eventually the app crashes.

I've based it on the RTPChannelTest class.

the call setup is as follows:

    sendSource = new Sine(scheduler);
    sendSource.setFrequency(100);        

    // set peer on sending channel. receiving channel has already been bound
    getSendChannel().setPeer(new InetSocketAddress(mediaServerAddress, sendRemotePort));

    getSendChannel().setFormatMap(AVProfile.audio);
    getRecvChannel().setFormatMap(AVProfile.audio);

    // setup an audio component to receive the input
    sendComponent=new AudioComponent(1);
    sendComponent.addInput(sendSource.getAudioInput());
    sendComponent.updateMode(true,true);

    // setup an audio mixer to receive the input; mix the send component and send channel
    sendAudioMixer=new AudioMixer(scheduler);
    sendAudioMixer.addComponent(sendComponent);
    sendAudioMixer.addComponent(getSendChannel().getAudioComponent());

and the tear down:

        sendSource.deactivate();
        sendChannel.close();
        recvChannel.close();
        sendAudioMixer.stop();
        udpManager.stop();
        scheduler.stop();

the problem appears to be in the Scheduler class, specifically the CriticalWorkerThread and the Worker thread where they remain in the WAITING state on the take statement (line 413) in

                try
                {
                    current=waitingTasks.take();
                }
                catch(Exception ex)
                {

                }                   

the Scheduler.stop() method only sets the 'active' boolean for the threads which can never be tested while the threads are in the WAITING state.

What is the correct way to stop the scheduler to prevent this thread leak?

I've thought of adding something to interrupt the threads, but there is an empty catch block which would just swallow the resultant interrupt.

Any guidance would be much appreciated as this is it makes my head hurt trying to get to grips with this code and how to fix my app or modify the code.

thanks, Mitchell

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions