ccrtp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ccrtp-devel] ccRTP memory usage not optimal for WIN32 build


From: hlabs
Subject: [Ccrtp-devel] ccRTP memory usage not optimal for WIN32 build
Date: Fri, 17 Feb 2012 04:24:08 -0800 (PST)

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

-- 
View this message in context: 
http://old.nabble.com/ccRTP-memory-usage-not-optimal-for-WIN32-build-tp33342302p33342302.html
Sent from the Gnu - ccRTP - Dev mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]