# TrimExcess()

> Removes any excess capacity in the buffer.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

```csharp
public void TrimExcess()
```

### Remarks

Sets the buffer capacity to the current length. If the buffer memory size changes, the current contents of the buffer are copied to a new block of memory and the old memory is freed. If the buffer now fits in the space in the chunk reserved with [InternalBufferCapacityAttribute](/engine/7000.0/script-reference/unity/entities/internalbuffercapacityattribute.md), then the buffer contents are moved to the chunk.
