BasicHttpBinding.MaxBufferPoolSize 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置从通道接收消息的消息缓冲区的管理器分配的最大内存量(以字节为单位)。
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
属性值
消息缓冲区管理器可以使用的最大内存量(以字节为单位)。 默认值为524288(0x80000)字节。
示例
以下示例将此属性设置为默认值的两倍。
BasicHttpBinding binding = new BasicHttpBinding();
// Use double the default value
binding.MaxBufferPoolSize = 0x80000 * 2;
也可以在配置文件中设置此属性的值。
<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 缓冲池将使用缓冲区的成本降到最低。 当消息从通道传出时,需要缓冲区由服务处理消息。 如果缓冲池中没有足够的内存来处理消息加载, BufferManager 则必须从 CLR 堆分配额外的内存,这会增加垃圾回收开销。 CLR 垃圾堆中的大量分配表明缓冲池大小太小,并且可以通过增加 MaxBufferPoolSize 限制来提高更大的分配性能。