logo       

Re: memory leak in udp roundtrip example?: msg#00029

lib.boost.asio.user

Subject: Re: memory leak in udp roundtrip example?

Hi Charlls,

Charlls Quarra wrote:
> Hi,
>
> I was trying to find the source of a leak in my asio
> application (nothing outrageously big, but it could
> exhaust 1Gb in a day or so), and i keep reducing the
> code until i reached a minimal skeleton that
> reproduces the leak. I'm not sure if it has been
> reported already since there are no bugs filed in the
> tracker, so i assume it's safe to post it here.

I was able to reproduce the problem you described, but the cause is
actually a small error in your program. The program starts new
async_receive_from operations in both handle_receive_from and
handle_send_to.

If you start multiple reads on a socket, they are added to an internal
queue and complete in order as data arrives. In the program the length
of this queue is increased by one for every packet that gets echoed.

I think all you need to do to fix the leak is to remove the
async_receive_from call from handle_send_to.

Cheers,
Chris


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise