unispeech / unimrcp

Open source cross-platform implementation of MRCP protocol
http://www.unimrcp.org
Apache License 2.0
374 stars 165 forks source link

memory leak when keep-alived connection #295

Closed lizhenghn123 closed 3 years ago

lizhenghn123 commented 3 years ago

hi, achaloyan, I have a problem. It would be memory leak when the mrcp connection is keep-alived(long connection).

I see the mrcp connection(with mrcp port: 21544) once created, it will alloc memory by at https://github.com/unispeech/unimrcp/blob/master/libs/mrcpv2-transport/src/mrcp_connection.c#L23, and the memory would not free until the connection closed, at https://github.com/unispeech/unimrcp/blob/master/libs/mrcpv2-transport/src/mrcp_connection.c#L52.

But if the mrcp connection is keep-alived, it means the connection don't close, it will be keep long time, may be some days. And many requests will be transfer on this connection, it caused alloc memory more and more, but can't release(because the connection is already alive, don't close). So the memory will be increase util 100%.

Now how to fix it ? may the apr library can be memory reuse or manual release?

I use valgrind tool to check the memory leak, like this: image

valgrind.txt

This is some information:

  1. mrcpserver veriosn: 1.5.0
  2. mrcpserver ip: 10.233.135.12
  3. ivr ip:10.233.129.106
  4. sip port: 20010, mrcp port: 21544;
  5. ivr will be create 5 mrcp connections, and 100 sip sessions;

    Some logs will be here. May you have some suggests ? Waiting for your reply, thanks a lot. unimrcpserver.log

lizhenghn123 commented 3 years ago

Can someone give some advice ?

achaloyan commented 3 years ago

Duplicates #294.