How to use OverlapBoxNonAlloc?

I understand how to use OverlapBoxAll perfectly, but the docs suggest using OverlapBoxNonAlloc if you’re going to be performing the check regularly. The main benefit being, “The significance of this is that no memory is allocated for the results”. But in order to store the results… don’t we have to allocate an array ahead of time? Here’s how I’m using the code now, I know it’s wrong but for the life of me I can’t find an example of how to actually implement it online.

		Collider2D[] colliders = new Collider2D[0]; // This of course will always return no results haha
		Physics2D.OverlapBoxNonAlloc(transform.position, colliderSize, 
		transform.localEulerAngles.z, colliders, LayerMask.GetMask("Default"));

I’m sure it has something to do with the way I’m initializing my array…

You need to specify a fixed size for your buffer. Have it a class member for instance - or a local variable if you want to batch a few calls only. If you create a new local buffer everytime before using Overlap-NonAlloc, it will defeat the purpose of trying to not reallocate memory.

private Collider2D[] m_buffer = new Collider2D[16]; // Use a fixed size that suits your need

You get the number of overlapping objects found as a return value.

int l_nb = Physics2D.OverlapBoxNonAlloc(pos, size, angle, buffer);

Then, you may perform something on these objects by using l_nb like so:

for(int i = 0; i < l_nb; i++) {
    // Do something on m_buffer

The reason for this is that there may be less overlapping objects than your fixed buffer size. Note that if on the other hand there are more overlapping objects, then the excess ones will be ignored.
It is a more controlled but efficient way of checking for overlapping objects. As stated in the Unity Doc, it is in the case you need to perform this check frequently as it will avoid excessive Garbage Collection.