# MemoryGrainStorage Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.persistence.memory/orleans.storage.memorygrainstorage/)

## ClearStateAsync(string, GrainId, IGrainState&lt;T&gt;) {#clearstateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-cfdcf895}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.memory/orleans.storage.memorygrainstorage/methods/clearstateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-cfdcf895/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Persistence.Memory/Storage/MemoryStorage.cs#L113-L127)

```csharp
public virtual Task ClearStateAsync<T>(string grainType, GrainId grainId, IGrainState<T> grainState)
```

Delete / Clear data function for this storage instance.

### Parameters

- `grainType` (`string`): Name of the state for this grain
- `grainId` (`GrainId`): Grain ID
- `grainState` (`IGrainState<T>`): Copy of last-known state data object for this grain.

### Returns

Completion promise for the Delete operation on the specified grain.

## Dispose {#dispose-56f87669}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.memory/orleans.storage.memorygrainstorage/methods/dispose-56f87669/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Persistence.Memory/Storage/MemoryStorage.cs#L138)

```csharp
public void Dispose()
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

## ReadStateAsync(string, GrainId, IGrainState&lt;T&gt;) {#readstateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-783100b4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.memory/orleans.storage.memorygrainstorage/methods/readstateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-783100b4/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Persistence.Memory/Storage/MemoryStorage.cs#L68-L86)

```csharp
public virtual Task ReadStateAsync<T>(string grainType, GrainId grainId, IGrainState<T> grainState)
```

Read data function for this storage instance.

### Parameters

- `grainType` (`string`): Name of the state for this grain
- `grainId` (`GrainId`): Grain ID
- `grainState` (`IGrainState<T>`): State data object to be populated for this grain.

### Returns

Completion promise for the Read operation on the specified grain.

## WriteStateAsync(string, GrainId, IGrainState&lt;T&gt;) {#writestateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-4578b227}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.memory/orleans.storage.memorygrainstorage/methods/writestateasync-1-string-orleans-runtime-grainid-orleans-igrainstate-t-4578b227/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Persistence.Memory/Storage/MemoryStorage.cs#L91-L108)

```csharp
public virtual Task WriteStateAsync<T>(string grainType, GrainId grainId, IGrainState<T> grainState)
```

Write data function for this storage instance.

### Parameters

- `grainType` (`string`): Name of the state for this grain
- `grainId` (`GrainId`): Grain ID
- `grainState` (`IGrainState<T>`): State data object to be written for this grain.

### Returns

Completion promise for the Write operation on the specified grain.
