Thanks, Egon!
Another questions:
1, You mentioned "newer" vm, my android version is 2.3.3, is this a "newer" vm? And my ADT is the latest version.
2, Does native-buffer have its own limit? Which i mean is that: if there are 16M free-mems left in vm, then could the max mem of native-buffer be 16M or only be some fixed limit which is smaller than 16M?
3, How many java-mem does world.draw use? How many native-mem does world.draw use? How to roughly estimate this?
4, I read an article from web, which says that: If a block of mem was alloced by java, it will not be reused by native even after this java-mem-block was recycled by GC(because of the mem-caching-mechanism of android). It not mentioned the version of android.
I don't know if this option is correct. But if it's correct, some of my doubts will be explained.
5, My codes with some doubts:
// new MyRenderer, when running this, free-mem is 3-4M.
initWorld();
initTexture();
initLight();
loadModel();
initCamera();
initAllAnimations();
// onSurfaceCreated
//do nothing
// onSurfaceChanged
initFrameBuffer(gl, width, height);
initFpsShown();
mFpsShown.fpsStart();
Main3DScene scene = SceneManager.getInstance().buildScene(SceneManager.SCENE_BEGIN, mWorld, mFrameBuffer, mDog);
SceneManager.getInstance().setCurrentScene(scene);
try
{
System.gc();
Log.d("jPCT-AE", "gc");
// free-mem will jumped from 3M to 12M, which means there are some mem was recycled by GC. So in this point, there was a 12-3=9M mem-increase.
Thread.sleep(10000); // waitting for GC
}
catch (InterruptedException e)
{
e.printStackTrace();
}
// onDrawFrame
SceneManager.getInstance().getCurrentScene().onDrawFrame(gl); // will call world.renderScene and world.draw, and the OOM happened here(world.draw).
mFpsShown.drawFps();
mFrameBuffer.display();
mFpsShown.calacFps();
My doubt is :
1, When new MyRenderer, DDMS says the free-mem is 3M.
2, When onSurfaceChanged, there is a mem-increase of 9M by GC. So, there is at least 9M free-mem left.
3, When onDrawFrame, OOM happened, but i don't think 9M is not enough for my situation. Could this happen:
There are enough mems left in heap, but some of them can't be alloced for native-buffer, so the mem-usage of native is not enough, so the OOM will happen.