旋转调用垃圾收集器经常Android MatrixMultiply

时间:2012-03-12 03:36:14

标签: android garbage-collection heap

美好的一天,

我正在Android上编写Open GL App。当我更新它们的位置,速度或加速度时,我有100个游戏对象执行得很好。在我的游戏循环中,我还希望能够在游戏对象的每次迭代中调用“偏航”(或俯仰或滚动)方法。问题是我导致垃圾收集器疯狂使用GC_CONCURRENT打印输出语句到LogCat。

在我的偏航方法中,我有以下呼叫......

reAlignVectors(); //No heap allocations in this method that I wrote
Matrix.rotateM(rotationArray,0,angle,0,1,0); //RotationArray is a float[16]
Matrix.setIdentityM(rotationalComputeArray,0); //Another float[16]
Matrix.rotateM(rotationalComputeArray,0,angle,upVector.x, upvector.y, upvector.z);
Matrix.multiplyMV(lookvector...
Matrix.multiplyMV(rightvector..

我已经注释掉了我将调用yaw方法的代码,并且我几乎没有调用垃圾收集器(GC),并且100个对象很容易在世界范围内移动而没有显着差异。当我取消注释偏航呼叫时,我的性能显着下降。对象移动不稳定,我得到所有的GC调用。

有人知道Matrix.multiplyMV或Matrix.rotateM是否在堆中重新分配内存?接缝是我唯一可以猜到的东西?如果是这样,有没有人知道如何预防或解决我所处的情况?

感谢您的帮助。

0 个答案:

没有答案
相关问题