Редагувати

Поділитися через


BasicHttpBinding.MaxBufferSize Property

Definition

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

public:
 property int MaxBufferSize { int get(); void set(int value); };
public int MaxBufferSize { get; set; }
member this.MaxBufferSize : int with get, set
Public Property MaxBufferSize As Integer

Property Value

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.

Examples

The following example sets MaxBufferSize to 1,000,000 bytes.

BasicHttpBinding binding = new BasicHttpBinding();

// set to one million
binding.MaxBufferSize = 1000000;

The value of this property can also be set in the configuration file.

Remarks

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 value of the MaxBufferSize property and its significance is different depending on whether the messages are being buffered or streamed on the channel through which they are being received:

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.

Note

The settings for MaxBufferSize and MaxReceivedMessageSize, 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 2GB from metadata, the proxy still has a default value of 64K. This leaves control of the appropriate bounds for message and message buffer size in the scope of local administrators.

Applies to