logo       

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

lib.boost.asio.user

Subject: Re: memory leak in udp roundtrip example?


--- Christopher Kohlhoff <chris-34HiQXrhQN1Wk0Htik3J/w@xxxxxxxxxxxxxxxx>
escribió:

> Hi Charlls,

Hi Chris :)

> 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.


ahh this was something that i wasn't clear about; what
happened when several async_receive_from calls
stacked; if they detected that for this port there was
already a receive in place, or they just got queued
and put in listening inmediately as the previous
returns to handle_receive_from, i know better now

>The data passed to async_send_to must be valid for
the lifetime of the
>operation (i.e. until the handler is called), but the
string argument
">str" in this function:

hmm, indeed, now i remember when the documentation
says in various places that the "async calls are
called only from the threads that run
io_service::run", now i realize why the insistence :)

thank you Chris, as always you have been incredibly
helpful. Hope you are well

Charlls


__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar

-------------------------------------------------------------------------
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