# MemoryStreamBufferWriter Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.adaptors.memorystreambufferwriter/)

## Advance(int) {#advance-int-3025b65d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.adaptors.memorystreambufferwriter/methods/advance-int-3025b65d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Adaptors/MemoryStreamBufferWriter.cs#L27-L28)

```csharp
public void Advance(int count)
```

Notifies the `System.Buffers.IBufferWriter-1` that `count` data items were written to the output `System.Span-1` or `System.Memory-1`.

### Parameters

- `count` (`int`): The number of data items written to the `System.Span-1` or `System.Memory-1`.

## GetMemory(int) {#getmemory-int-8074ab55}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.adaptors.memorystreambufferwriter/methods/getmemory-int-8074ab55/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Adaptors/MemoryStreamBufferWriter.cs#L33-L44)

```csharp
public Memory<byte> GetMemory(int sizeHint = 0)
```

Returns a `System.Memory-1` to write to that is at least the requested size (specified by `sizeHint`).

### Parameters

- `sizeHint` (`int`): The minimum length of the returned `System.Memory-1`. If 0, a non-empty buffer is returned.

### Returns

A `System.Memory-1` of at least the size `sizeHint`. If `sizeHint` is 0, returns a non-empty buffer.

### Exceptions

- `System.OutOfMemoryException`: The requested buffer size is not available.

## GetSpan(int) {#getspan-int-92adf7d7}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.adaptors.memorystreambufferwriter/methods/getspan-int-92adf7d7/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Adaptors/MemoryStreamBufferWriter.cs#L50-L61)

```csharp
public Span<byte> GetSpan(int sizeHint = 0)
```

Returns a `System.Span-1` to write to that is at least the requested size (specified by `sizeHint`).

### Parameters

- `sizeHint` (`int`): The minimum length of the returned `System.Span-1`. If 0, a non-empty buffer is returned.

### Returns

A `System.Span-1` of at least the size `sizeHint`. If `sizeHint` is 0, returns a non-empty buffer.
