Home Dashboard Directory Help
Search

SocketAsyncEventArgs leaks its memory unless manually disposed by ayalx


Status: 

Closed
 as Won't Fix Help for as Won't Fix


1
0
Sign in
to vote
Type: Bug
ID: 736066
Opened: 4/9/2012 11:03:04 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

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.
Details
Sign in to post a comment.
Posted by Alex780526 on 10/3/2013 at 6:53 AM
Hi,

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.

Alex
Posted by Chris Muench, C-Labs LLC 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(http://support.microsoft.com)
Sign in to post a workaround.