BasicHttpBinding.MaxBufferSize Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the maximum size for a buffer that receives messages from the channel.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)


Public Property MaxBufferSize As Integer
public int MaxBufferSize { get; set; }

Property Value

Type: System.Int32
The maximum size, in bytes, of a buffer that stores messages while they are processed for an endpoint configured with this binding. The default value is 65,536 bytes.


If there is not sufficient memory in the buffer to store the message while it is processed, more memory must be allocated from the CLR heap, which increases the garbage collection overhead. Extensive allocation from the CLR garbage heap is an indication that the message buffer size is too small and that performance can be improved with a larger allocation.

The limitations on buffer size set here are for optimizing the performance of message exchanges. If a message exceeds the maximum value set for the buffer, it is not dropped. Instead, more memory is requested from the CLR heap and this incurs more garbage collection overhead than using the buffers.


The settings for the MaxBufferSize and MaxReceivedMessageSize properties are local behavioral settings. This means that they are not transmitted to other endpoints in metadata. If you generate a proxy to a service with a maximum message size of 2 GB from metadata, the proxy still has a default value of 64 KB. This leaves control of the appropriate bounds for message and message buffer size in the scope of local administrators.


            ' Get default MaxBufferSize
            Dim maxBufferSize As Integer = binding.MaxBufferSize
            'Output of txtMBS to TextBlock: 65536
            Dim txtMBS As String = maxBufferSize.ToString()

            ' Set new MaxBufferSize
            binding.MaxReceivedMessageSize = 4096
            Dim txtNewMBS As String = binding.MaxReceivedMessageSize.ToString()
// Get default MaxBufferSize
int maxBufferSize = binding.MaxBufferSize;
//Output of txtMBS to TextBlock: 65536
string txtMBS = maxBufferSize.ToString();

// Set new MaxBufferSize
binding.MaxReceivedMessageSize = 4096;
string txtNewMBS = binding.MaxReceivedMessageSize.ToString();

Version Information


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.