# Cleanup(bool)

> Releases the allocated resources of this PaintContext.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.TerrainTools](/engine/6000.5/script-reference/unityengine/terraintools.md)
* **Assembly:** UnityEngine.TerrainModule

```csharp
public void Cleanup(bool restoreRenderTexture = true)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): When true, indicates that this function restores RenderTexture.active

### Remarks

This function releases the `sourceRenderTexture` and `destinationRenderTexture`. When restoreRenderTexture is true, it also restores RenderTexture.active to the value saved as \_oldRenderTexture. This function is called internally by [TerrainPaintUtility.EndPaintHeightmap](/engine/6000.5/script-reference/unityengine/terraintools/terrainpaintutility/endpaintheightmap.md), [TerrainPaintUtility.EndPaintTexture](/engine/6000.5/script-reference/unityengine/terraintools/terrainpaintutility/endpainttexture.md) and [TerrainPaintUtility.ReleaseContextResources](/engine/6000.5/script-reference/unityengine/terraintools/terrainpaintutility/releasecontextresources.md).
