G
Guest
Hi, I am migrating an application from .NET 1.1 to .NET 2.0. It is a network
application that use asynchronous sockets intensively (with more than 300
active connections on average)
With .NET 1.1 I had problems because the buffers used in the BeginReceive
and BeginSend calls were pinned and prevented the heap to be compacted by the
GC. I managed to solve this problem by allocating the buffers at the
application start up using a buffer pool.
Now, in the same application, compiled with .NET 2.0 the heap is heavily
fragmented. I can see with perfmon that the pinned objects counter is about 4
times the number of pending asynchronous calls (it was exactly equal in .Net
1.1), so it seems that .NET 2.0 pins 4 objects for each asynchronous socket
call instead of pinning only the buffer.
This make senseless the approach of using a buffer pool (I get the same
memory footprint in .NET 2.0 using the buffer pool or not using it). And the
improvements done in .NET 2.0 in managing pinned objects are not good enough,
so the situation became worse.
Am I wrong with this conclusion? If not, Is there any workaround for this?
or a way I can do that the asynchronous socket calls pins only the
sending/receiving buffer? What other objects is .NET 2.0 pinning in the asyn
socket calls?
Thanks
application that use asynchronous sockets intensively (with more than 300
active connections on average)
With .NET 1.1 I had problems because the buffers used in the BeginReceive
and BeginSend calls were pinned and prevented the heap to be compacted by the
GC. I managed to solve this problem by allocating the buffers at the
application start up using a buffer pool.
Now, in the same application, compiled with .NET 2.0 the heap is heavily
fragmented. I can see with perfmon that the pinned objects counter is about 4
times the number of pending asynchronous calls (it was exactly equal in .Net
1.1), so it seems that .NET 2.0 pins 4 objects for each asynchronous socket
call instead of pinning only the buffer.
This make senseless the approach of using a buffer pool (I get the same
memory footprint in .NET 2.0 using the buffer pool or not using it). And the
improvements done in .NET 2.0 in managing pinned objects are not good enough,
so the situation became worse.
Am I wrong with this conclusion? If not, Is there any workaround for this?
or a way I can do that the asynchronous socket calls pins only the
sending/receiving buffer? What other objects is .NET 2.0 pinning in the asyn
socket calls?
Thanks