我對Bitmap.createBitmap()的調用總是會導致gc_for_alloc。 下面是代碼:當我調用Bitmap.createBitmap()時如何避免gc_for_alloc?
if (theFinger.isTheSaveFlag())
{
theBackGroundBuffer.position(0);
gl.glReadPixels(0, 0, theBackGroundWidth, theBackGroundHeight, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, theBackGroundBuffer);
theBackGroundBuffer.position(0);
theBackGroundBuffer.get(theBackGroundPixel);
theBackGroundTexture.dispose();
theBackGround.recycle();
theBackGround = Bitmap.createBitmap(theBackGroundPixel, theBackGroundWidth, theBackGroundHeight, Bitmap.Config.ARGB_8888);
theBackGroundTexture.load(theBackGround);
}
有人能告訴我爲什麼嗎?
logcat中的'GC_FOR_ALLOC'消息是正常的。當新內存分配需要內存時,垃圾收集器正在完成其工作。你面臨的具體問題是什麼? – laalto