---
title: Dispose()
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/weightmasksampler/dispose
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/weightmasksampler/dispose.md
last_updated: 2026-11-30
generated_at: 2026-11-30T21:39:22.317Z
locale: en-us
---

# Dispose()

> Releases the memory of the sampler.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Animations](/engine/7000.0/script-reference/unity/animations.md)
* **Assembly:** [UnityEngine.AnimationCoreModule](/engine/7000.0/script-reference/modules/unityengine-animationcoremodule.md)

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

### Remarks

Copies of the sampler share the same memory. Call this method on only one copy, and don't use the other copies or the masks that you created from the sampler afterward. A sampler from [WeightMaskSampler.Clone](/engine/7000.0/script-reference/unity/animations/weightmasksampler/clone.md) has its own memory, so this method doesn't affect it. This method has no effect on a default sampler.

If safety checks are enabled, a second call to this method throws an `ObjectDisposedException` on any copy. For a sampler that uses [Allocator.Temp](/engine/7000.0/script-reference/unity/collections/allocator/temp.md), the safety system doesn't detect that you use another copy after this call, as for other containers that use [Allocator.Temp](/engine/7000.0/script-reference/unity/collections/allocator/temp.md). The memory stays valid until the end of the scope of the temporary allocations.
