---
title: endCommandBuffer()
framework: metal
role: symbol
role_heading: Instance Method
path: metal/mtl4commandbuffer/endcommandbuffer()
---

# endCommandBuffer()

Closes a command buffer to prepare it for submission to a command queue.

## Declaration

```swift
func endCommandBuffer()
```

## Mentioned in

Understanding the Metal 4 core API

## Discussion

Discussion Explicitly ending the command buffer allows you to reuse the MTL4CommandAllocator to start servicing other command buffers. It is an error to call commit on a command buffer previously recording before calling this method.
