BasicHttpBinding.MaxBufferPoolSize BasicHttpBinding.MaxBufferPoolSize BasicHttpBinding.MaxBufferPoolSize BasicHttpBinding.MaxBufferPoolSize Property

定义

获取或设置为从通道接收消息的消息缓冲区管理器分配并供其使用的最大内存量(以字节为单位)。Gets or sets the maximum amount of memory, in bytes, that is allocated for use by the manager of the message buffers that receive messages from the channel.

public:
 property long MaxBufferPoolSize { long get(); void set(long value); };
public long MaxBufferPoolSize { get; set; }
member this.MaxBufferPoolSize : int64 with get, set
Public Property MaxBufferPoolSize As Long

属性值

可供消息缓冲区管理器使用的最大内存量(以字节为单位)。The maximum amount of memory, in bytes, available for use by the message buffer manager. 默认值为 524288 (0x80000) 字节。The default value is 524288 (0x80000) bytes.

示例

下面的示例将此属性设置为默认值的二倍。The following example sets this property to twice the default value.

BasicHttpBinding binding = new BasicHttpBinding();
// Use double the default value
binding.MaxBufferPoolSize = 0x80000 * 2;

也可以在配置文件中设置此属性的值。The value of this property can also be set in the configuration file.

<configuration>
  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="Binding1">

          <!-- set pool size to double default of 0x80000 -->
          maxBufferPoolSize = 0x100000

          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

  </system.serviceModel>

</configuration>

注解

通过使用缓冲池,BufferManager 将使用缓冲区的成本降至最低。The BufferManager minimizes the cost of using buffers by using a buffer pool. 当消息离开通道时,服务需要使用缓冲区来处理这些消息。Buffers are required to process messages by the service when they come out of the channel. 如果缓冲池中的内存不足,无法处理消息负载,则 BufferManager 必须从 CLR 堆分配更多内存,而这会增加垃圾回收的系统开销。If there is not sufficient memory in the buffer pool to process the message load, the BufferManager must allocate additional memory from the CLR heap, which increases the garbage collection overhead. 从 CLR 垃圾堆中进行大量分配是指缓冲池大小太小,并且通过增加 MaxBufferPoolSize 限制,可以使用较大的分配来改进性能。Extensive allocation from the CLR garbage heap is an indication that the buffer pool size is too small and that performance can be improved with a larger allocation by increasing the MaxBufferPoolSize limit.

适用于