NonAlloc in Unity is either deprecated or ineffective

Hi, just felt worth mentioning... I noticed Rider suggests "Use non-allocating method for ..." e.g. 'OverlapCircleNonAlloc'. But a Unity developer over at the Unity forums say they are deprecated or "tentatively deprecated".

His exact quote: 

"Yeah, it's technically not deprecated because it would cause a lot of users to be frustrated but all 2D queries with "NonAlloc" suffix are tentatively deprecated. All 2D queries (without exception) have an overload that replaces these calls (that take an array) and also accept a list.

OverlapCircleNonAlloc -> OverlapCircle
RaycastNonAlloc -> Raycast




could you please share the code that produces this suggestion for you? Also, which version of Rider do you use?

I've hit something to hide it, so I'm having difficulties to find all of the code that produces it. But it always appeared for "NonAlloc" versions of Physics rays/casts/checks. 
Physics2D.OverlapCircle(origin, radius);
// will suggest ....
Guessing it's the same for CircleCast vs CircleCastNonAlloc etc.
JetBrains Rider 2023.1.2 (macOS)


Has it appeared in code completion suggestions for you, or did you have an error or a warning produced by a usage of Physics2D.OverlapCircle()? Would it be possible for you to provide a screenshot?

Thank you in advance.


Unfortunately I can't provide a screenshot. I clicked something to make the suggestions disappear, and I can't find where to get them back for testing. However, this was the link from the suggestions: 

I've tried to re-enable them in the Inspection Severity window, just for testing, but it doesn't seem to bring back the suggestions (see screen shot).

All I can say is sometimes when I typed "Physics2D.OverlapCircle" it suggested the "Physics2D.OverlapCircleNonAlloc", probably when dealing with arrays, but all "NonAlloc" suffixes seems to be tentatively deprecated according to Unity. 



Thank you for the details. As far as I understand from your description, you are referring to non-allocating methods popping up in completion suggestions. Unfortunately there's currently no way to exclude specific suffixes from completion suggestion, apologies about that. Feel free to submit a new feature request to our tracker.

Since these methods are not completely deprecated and are still present in the Unity API, they will be present in the completion suggestions. 

Let me know if you have any other questions. Have a great day!


Please sign in to leave a comment.