Skip to content

UNI019: Collection allocation in hot path

What and why

Collection or array allocation inside MonoBehaviour per-frame methods (Update, FixedUpdate, LateUpdate, OnGUI, coroutines). Reuse buffers or pre-allocate outside hot paths.

Allocating collections every frame increases GC pressure.

How to fix: reuse lists/arrays or pre-allocate outside hot paths.

Fix guidance

Reuse buffers or pre-allocate collections outside hot paths.

Tags

performance, unity

Suppression

Use // unilyze-disable-next-line UNI019 -- reason immediately before the reported line. These detector findings are line-based, so separate overload occurrences can be suppressed independently. For project-wide suppression, use "rules": { "UNI019": "off" }; use a baseline to freeze existing findings while reporting new ones.