Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 638979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:47:29+00:00 2026-05-13T20:47:29+00:00

Reading through the SendAsync , BeginAsync method illustrations of Socket s, I realized that

  • 0

Reading through the SendAsync, BeginAsync method illustrations of Sockets, I realized that it was suggested to pool SocketAsyncEventArgs instances saying that it is a better than BeginXX, EndXX async approach since each call creates an IAsyncResult instance.

I thought it was not that a great practice to pool objects that can be instantiated easily (such as SocketAsyncEventArgs). Object allocation is pretty fast and GC is optimized to handle short living objects efficiently. I tried that out implementing a pooling mechanism to see how it performs, actually allocation is faster on simple objects that do nothing but encapsulate some data in ctor. (Well, it was like profiling a DBMS by sending billions of SELECT 1 statements, that’s why I’m here.)

I’m not asking which is better, I believe profiling the actual application would yield the answer but just curious about the benefits of pooling simple short living objects. Better GC performance? Low memory fragmentation? Does it worth to consider it during design?

From MSDN

The main feature of these enhancements
is the avoidance of the repeated
allocation and synchronization of
objects during high-volume
asynchronous socket I/O. The Begin/End
design pattern currently implemented
by the System.Net.Sockets.Socket class
requires a System.IAsyncResult object
be allocated for each asynchronous
socket operation.

In the new System.Net.Sockets.Socket
class enhancements, asynchronous
socket operations are described by
reusable SocketAsyncEventArgs objects
allocated and maintained by the
application. High-performance socket
applications know best the amount of
overlapped socket operations that must
be sustained. The application can
create as many of the
SocketAsyncEventArgs objects that it
needs. For example, if a server
application needs to have 15 socket
accept operations outstanding at all
times to support incoming client
connection rates, it can allocate 15
reusable SocketAsyncEventArgs objects
for that purpose.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:47:29+00:00Added an answer on May 13, 2026 at 8:47 pm

    The IAsyncResult interface includes an AsyncWaitHandle property of type WaitHandle. A WaitHandle consumes operating system resources.

    In fact, WaitHandle implements the IDisposable interface, so the class implementing IAsyncResult should itself implement IDisposable.

    This is all to say that hundreds of IAsyncResult instances lying around is not a memory issue – it’s a resources issue. The new socket calls get rid of the need for hundreds of IDisposable objects lying around.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading through the Zend Framework coding standards , where they state that curly
Reading through the Flickr API documentation it keeps stating I require an API key
Reading through this question on multi-threaded javascript, I was wondering if there would be
I'm reading through head first design patterns at the moment and while the book
I have been reading through the C++ FAQ and was curious about the friend
I've been reading through a lot of the rookie Java questions on finalize() and
recently I've been reading through Scott Meyers's excellent Effective C++ book. In one of
I'm reading through K&R and came to the small section on register variables, and
I've been reading through the details of the System libraries set and get methods
I'm reading through A Gentle Introduction to Haskell, and early on it uses this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.