当前位置: 动力学知识库 > 问答 > 编程问答 >

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

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: