[Mono-list] Async sockets and memory leaks in BeginSend
Nicholas Frechette
zeno490 at gmail.com
Sat May 26 16:07:15 UTC 2012
Dispose on async results is mostly to properly clear the
synchronization object (AsyncWaitHandle).
You can call dispose manually after calling EndSend(..) on the
AsyncWaitHandle. I do not believe this is required. It should be
called internally automatically.
This will not however fix the memory leak (I did try it myself). The
leak appears to be within the runtime, on the native side.
We'll just have to wait and see if it is indeed fixed. Btw here is the
link to the bug report I filled for this:
https://bugzilla.novell.com/show_bug.cgi?id=723148
https://bugzilla.novell.com/show_bug.cgi?id=731579
Have you tried without --debug to see if it still leaks?
On Thu, May 24, 2012 at 2:46 PM, xplicit <svg at ngs.ru> wrote:
> Thank you for you suggestion.
>
> SocketAsyncResult has Dispose method in it's implementation, but how could I
> call Dispose on SocketAsyncResult if this class is internal? BeginSend
> returns IAsyncResult interface, which does not have Dispose in the interface
> definition.
>
> I found some old posts in the internet about similar issue with
> OverlappedAsyncResult (internal implementation of IAsyncResult in BeginSend
> in .NET). They told, that in .NET 1.1 there was a memory leak in similar
> scenarious, because buffer was pinned and memory could not be defragmented
> by GC. Also, they told, that in .NET 2.0 such issue was fixed.
>
> They recommended to pool buffers to prevent reallocating them in memory. I
> followed this advice and removed creation of SendStateObject from the Send
> function. Creation SendStateObject only one time per each client in class
> constructor helped me to minimize memory leaks, so they now not so huge, but
> still present.
>
>
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/Async-sockets-and-memory-leaks-in-BeginSend-tp4648844p4649533.html
> Sent from the Mono - General mailing list archive at Nabble.com.
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
More information about the Mono-list
mailing list