Skip to content

UNI018: LINQ in hot path

What and why

LINQ query or operator inside MonoBehaviour per-frame methods (Update, FixedUpdate, LateUpdate, OnGUI, coroutines). LINQ allocates enumerators and often intermediate collections.

LINQ in per-frame methods allocates enumerators and intermediate collections.

How to fix: replace with explicit loops and reusable buffers.

Fix guidance

Replace LINQ with non-allocating loops in per-frame methods.

Tags

performance, unity

Suppression

Use // unilyze-disable-next-line UNI018 -- 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": { "UNI018": "off" }; use a baseline to freeze existing findings while reporting new ones.