[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ccrtp-devel] ccRTP memory usage not optimal for WIN32 build
From: |
Werner Dittmann |
Subject: |
Re: [Ccrtp-devel] ccRTP memory usage not optimal for WIN32 build |
Date: |
Sun, 19 Feb 2012 10:33:38 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120129 Thunderbird/10.0 |
Hi,
thanks, a good catch.
Who will fix it? I can do it if nobody opposes :-) .
Regards,
Werner
Am 17.02.2012 13:24, schrieb hlabs:
>
> hi,
>
> i'm using ccrtp 1.8.0 on win32.
>
> Memory usage for IncomingDataQueue is not optimal for WIN32 build.
> Look at code :
>
> size_t
> IncomingDataQueue::takeInDataPacket(void)
> {
> InetHostAddress network_address;
> tpport_t transport_port;
>
> uint32 nextSize = (uint32)getNextDataPacketSize();
>
>
> unsigned char* buffer = new unsigned char[nextSize];
> int32 rtn =
> (int32)recvData(buffer,nextSize,network_address,transport_port);
> if ( (rtn < 0) || ((uint32)rtn > getMaxRecvPacketSize()) ){
> delete buffer;
> return 0;
> }
>
> ....
>
> getNextDataPacketSize() returns size of all data in receive socket buffer,
> not data for one recv call.
> So if i'm set socket receive buffer (by SO_RECVBUF) to something large (
> 65535 for example), memory allocated for incoming packet may be greater than
> one packet size. This leads to huge memory usage after some hours of running
> app at high network load. I changed code to receive data to fixed size
> buffer (getMaxRecvPacketSize()) then new and memcpy only rtn bytes.
> Performance drop not noticable, but memory usage back to normal.
>
>
> New code:
>
> unsigned char buf[65535];
>
> if (nextSize > getMaxRecvPacketSize()) nextSize =
> getMaxRecvPacketSize();
>
> int32 rtn = (int32)recvData((unsigned
> char*)&buf,nextSize,network_address,transport_port);
> if ( (rtn < 0) || ((uint32)rtn > getMaxRecvPacketSize()) ){
> return 0;
> }
>
> unsigned char* buffer = new unsigned char[rtn];
> memcpy(buffer, &buf, rtn);
> ....
>
> .thanx
>