why gc alloc occured in this short simple code?

the code is

public class testItem
{
public int k = 0;

}

public class gctest : MonoBehaviour
{

    private testItem[] _ts = new testItem[100];
    private int i = 0;

	void Update ()
    {
        if (i <= _ts.Length - 1)
        {
            _ts *= new testItem();*

i++;
}

  • }*
    }
    and here’s snapshot of profiler.
    [90290-02.png|90290]*

as you see, gctest raise a gc allocates.
but i dont’ think that _ts = new testItem(); is not gabage. because _ts[] is a member variable, not local variable.
where is my mistaken idea?

It is because every frame (until the end) you create a new instance of a class. When you allocate the array, you only create place for references, not the classes themselves. You are better off initializing all the elements in a single frame or 10 each frame.