BasicHttpBinding.MaxBufferSize Propriedade
Definição
Obtém ou define o tamanho máximo, em bytes, para um buffer que recebe mensagens do canal.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
Valor da propriedade
O tamanho máximo, em bytes, de um buffer que armazena mensagens enquanto elas são processadas para um ponto de extremidade configurado com essa associação.The maximum size, in bytes, of a buffer that stores messages while they are processed for an endpoint configured with this binding. O valor padrão é 65.536 bytes.The default value is 65,536 bytes.
Exemplos
O exemplo a seguir define MaxBufferSize como 1 milhão bytes.The following example sets MaxBufferSize to 1,000,000 bytes.
BasicHttpBinding binding = new BasicHttpBinding();
// set to one million
binding.MaxBufferSize = 1000000;
O valor dessa propriedade também pode ser definido no arquivo de configuração.The value of this property can also be set in the configuration file.
Comentários
Se não houver memória suficiente no buffer para armazenar a mensagem enquanto ela é processada, mais memória deverá ser alocada a partir do heap do CLR, o que aumenta a sobrecarga da coleta de lixo.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. A alocação extensiva do heap de lixo do CLR é uma indicação de que o tamanho do buffer de mensagens é muito pequeno e que o desempenho pode ser melhorado com uma alocação maior.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.
O valor da propriedade MaxBufferSize e seu significado é diferente dependendo se as mensagens estão sendo armazenadas em buffer ou transmitidas no canal por meio do qual estão sendo recebidas: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:
Para transportes em buffer ( TransferMode definidos como TransferMode.Buffered ), esse valor é sempre igual ao especificado pela MaxReceivedMessageSize propriedade.For buffered transports (TransferMode set to TransferMode.Buffered), this value is always equal to that specified by the MaxReceivedMessageSize property.
Para transportes transmitidos ( TransferMode definidos como TransferMode.Streamed ), somente os cabeçalhos SOAP devem ser armazenados em buffer para gerar a mensagem.For streamed transports (TransferMode set to TransferMode.Streamed), only the SOAP headers must be buffered to generate the message. O corpo pode ser transmitido sob demanda.The body can be streamed in on-demand. Nesse caso, o MaxBufferSize é menor ou igual a MaxReceivedMessageSize , onde MaxReceivedMessageSize limita o tamanho da mensagem geral (cabeçalhos e corpo) e MaxBufferSize limita apenas o tamanho dos cabeçalhos SOAP.In this case, MaxBufferSize is less than or equal to MaxReceivedMessageSize, where MaxReceivedMessageSize bounds the size of the overall message (headers and body) and MaxBufferSize bounds only the size of the SOAP headers.
As limitações no tamanho do buffer definido aqui são para otimizar o desempenho das trocas de mensagens.The limitations on buffer size set here are for optimizing the performance of message exchanges. Se uma mensagem exceder o valor máximo definido para o buffer, ela não será descartada.If a message exceeds the maximum value set for the buffer, it is not dropped. Em vez disso, mais memória é solicitada do heap do CLR e isso incorre em mais sobrecarga de coleta de lixo do que usar os buffers.Instead, more memory is requested from the CLR heap and this incurs more garbage collection overhead than using the buffers.
Observação
As configurações para MaxBufferSize e MaxReceivedMessageSize são configurações de comportamento local.The settings for MaxBufferSize and MaxReceivedMessageSize, are local behavioral settings. Isso significa que eles não são transmitidos para outros pontos de extremidade nos metadados.This means that they are not transmitted to other endpoints in metadata. Se você gerar um proxy para um serviço com um tamanho máximo de mensagens de 2GB de metadados, o proxy ainda terá um valor padrão de 64K.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. Isso deixa o controle dos limites apropriados para a mensagem e o tamanho do buffer de mensagens no escopo dos administradores locais.This leaves control of the appropriate bounds for message and message buffer size in the scope of local administrators.