Message.Expand

Method

Visual Basic

Public Sub Expand(
    ByVal additionalStorage As UInt32)

C#

public void Expand(
    uint additionalStorage);

Purpose

Enlarge a message by allocating additional storage.

Remarks

.NET programs store messages in unmanaged objects. When adding data to a message would overflow the allocated space, the message automatically expands by allocating additional storage. However, reallocation (whether explicit or automatic) is a slow operation; to optimize program performance, we recommend allocating sufficient storage initially, so that reallocation is not required.

If no space is available, this method throws an exception with the error code NoMemory.

Parameter

Description

additionalStorage

Enlarge the message by this amount (in bytes) to allocate for the message. If the message was oldSize bytes before this call, it is oldSize + additionalStorage when the method returns.