问题描述:

Libgdx does creating array of float(primitive type) every frame fire garbage collection?:

 public void update(float delta)

{

float[] vert = new float[15];

}

网友答案:

I think what you mean is... If you create an array of floats every frame, will it trigger garbage collection.

If that is indeed what you meant, then the answer is yes, it definitely would eventually cause a garbage collection to be triggered.

A better way to do it would be to assign the array up-front and reuse it, or alternatively use a libgdx FloatArray and clear it at the start of each frame.

相关阅读:
Top