SocketAsyncEventArgs leaks its memory unless manually disposed - by Dag dennis

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 736066 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 4/9/2012 11:03:04 AM
Access Restriction Public


Each time the program use SendAsync(), ReciveAsync or AcceptAsync with a new SocketAsyncEventArgs object, the object is never collected by the GC.
The ThreadPool continues to hold a reference to the object, and it doesn't release it even after the operation completes.
The only way to solve this issue is to call Dispose()on the object after the operation completes.
Sign in to post a comment.
Posted by Alex780526 on 10/3/2013 at 6:53 AM

yes, it is right that without calling Dispose you will leak memory, but this should not be a problem because the basic idea of SocketAsyncEventArgs and *Async methods programming model is that you can reuse the Args object as many times as you wish. Reusing it for continuous sending (or receiving) data does not leak memory, just Dispose it, when you will not use for any other operation to prevent the leak.

Posted by Chris Muench, C-Labs Corp on 5/8/2012 at 3:37 PM
I concur with this statement...I am calling SendAsync 32 times per second and everytime I (have to) create a new "SocketAsyncEventArgs" object. After about 10 minutes I see constant memory usage in my app pointing to not-released SocketAsyncEventArgs. (Using .NET 4 on a Windows 8 CP)
Posted by Microsoft on 4/10/2012 at 3:52 PM
Regretfully, we are unable to take this bug at this time.
Posted by MS-Moderator10 [Feedback Moderator] on 4/9/2012 at 7:29 PM
Thanks for your feedback. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 4/9/2012 at 6:48 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(