# ArgumentException: Command buffer overflow. Cannot push more commands. The maximum capacity is 2048.

- **ID:** `unity/rendering-command-buffer-overflow`
- **Domain:** unity
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

A script or shader pushes too many commands into a CommandBuffer, exceeding the default capacity of 2048 commands.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2021.3 | active | — | — |
| 2022.3 | active | — | — |
| 2023.2 | active | — | — |

## Workarounds

1. **Batch commands using CommandBuffer.Clear before pushing new ones. For example, in an Update loop, call cmdBuffer.Clear() at the start of each frame and rebuild only necessary commands.** (90% success)
   ```
   Batch commands using CommandBuffer.Clear before pushing new ones. For example, in an Update loop, call cmdBuffer.Clear() at the start of each frame and rebuild only necessary commands.
   ```
2. **Reduce command count by merging draw calls with MaterialPropertyBlock or using GPU instancing. Replace per-object draw calls with a single DrawMeshInstanced.** (85% success)
   ```
   Reduce command count by merging draw calls with MaterialPropertyBlock or using GPU instancing. Replace per-object draw calls with a single DrawMeshInstanced.
   ```
3. **Set CommandBuffer's maximum capacity via reflection (not recommended for production) or offload some commands to a compute shader.** (60% success)
   ```
   Set CommandBuffer's maximum capacity via reflection (not recommended for production) or offload some commands to a compute shader.
   ```

## Dead Ends

- **** — CommandBuffer capacity is hardcoded internally; no public API exists to change it. Attempting to do so causes compilation errors. (90% fail)
- **** — Removing CommandBuffers may break custom rendering effects like outlines or post-processing. (50% fail)
- **** — Changing pipeline requires rewriting shaders and materials, which is a large refactor and may not resolve buffer overflow. (70% fail)
