memory issues

Started by raft, October 15, 2010, 02:52:55 PM

Previous topic - Next topic

EgonOlsen

BTW: Are you using 16bit textures or 32bit?

raft

@Override
protected void onPause() {
super.onPause();
Log.i(LOG_TAG, "onPause");

// omited irrelevant code
mGLView.onPause();

if (wakeLock.isHeld())
wakeLock.release();

if (renderer.buffer != null)
renderer.buffer.freeMemory();
}


@Override
protected void onStop() {
super.onStop();
Log.i(LOG_TAG, "onStop");
//renderer.stop();
if (renderer.buffer != null)
renderer.buffer.freeMemory();
}


i dispose FrameBuffer at two locations: in Renderer.onSurfaceChanged(..) and in Activity.onCreate(..) if last activity instance is not null

for texture bits i'm not sure. if you are asking if i'm calling Texture.enable4bpp(..), i do not.

EgonOlsen

Quote from: raft on October 18, 2010, 01:40:54 PM
for texture bits i'm not sure. if you are asking if i'm calling Texture.enable4bpp(..), i do not.
It's 32bit then...maybe going to 16bit helps!?

raft

yes, calling Texture.enable4bpp(true); helped ;D
what is exactly happening here ? do we just lower memory usage ?

EgonOlsen

Textures use half the memory then but it might introduce color banding. I've never noticed it unless i explicitly watched out for it.

raft

i see. so we still dont know the source of the problem. we just lowered memory usage

EgonOlsen

If you are coming close to Dalvik's memory limit (and you obviously do...) especially native memory reservations start to act crazy. As said, i had similar issues when loading images (which seems to use some native memory internally). Behavior was unpredictable...sometimes it worked, sometimes it failed. Googling the issue resulted in similar problems all over the place but no real solution... :(
The compact()-method in the memory helper is the result of this...

However, i can still bring memory usage down by 0-1MB and i'll add that to the next version. In addition, you could prevent textures used for blitting only from using mipmapping, if you haven't already done that.

raft

all these fixes perform very well. i'm using a skybox with six 512x512 textures and didnt get any out of memory yet ;D