I have a WCF service that processes a very large number of requests (thousands per second). Each request contains objects, so they are created inside the DataContractSerializer during deserialization. My service processes the messages and they are cleared by the .net garbage collector.
The problem is that garbage collection causes problems for my service (sometimes requests are 100 Ξs more than they should). I need to keep them to a minimum. Therefore, I am looking for a way to use a pool of objects. In other words, I want the data serializer to be able to get the object from the object pool (instead of getting it through GetUninitializedObject), and then when I finished processing the message, I released it back to the pool for cleaning and reuse, thereby avoiding thousands of memory allocations per second.
I saw that this is possible with protobuf-net ( Using protobuf-net, is it possible to deserialize a message without allocating memory? ) And actually I'm using protobuf elsewhere, but for this particular situation, which is not an option
source share