If you profile a simple client application that uses SocketAsyncEventArgs
, you will notice Thread
and ExecutionContext
allocations.
The source of the allocations is SocketAsyncEventArgs.StartOperationCommon
that creates a copy of the ExecutionContext with ExecutionContext.CreateCopy()
.
ExecutionContext.SuppressFlow
seems like a good way to suppress this allocation. However this method itself will generate allocations when ran in a new thread.
How can I avoid these allocations?