How can I prevent BufferManager / PooledBufferManager in my WCF client app from wasting memory?

I believe I have answer to your question #5:

5) Or maybe even better, could we just tell all HttpsChannelFactory
instances NOT to use BufferManagers at all and ask the GC to do
its god-damn job, which is ‘managing memory’?

There is a MaxBufferPoolSize binding parameter, which controls max size of buffers in BufferManager. Setting it to 0 will disable buffering, and GCBufferManager will be created instead of pooled one – and it will GC allocated buffers as soon as message is processed, as in your question.

This article discusses WCF memory buffer management in greater detail.

Leave a Comment