Reputation: 908
In my Android game, I have some Activities, one of them has an OpenGL view. The problem is each time I switch between activities, the used heap memory doesn't free up, so for example after 10-20 times switching between Activities in some phones, Application crashes and close.
I have this structure code For switching between every Activity:
Intent it = new Intent(WorldChose.this, MainMenu.class);
startActivity(it);
overridePendingTransition(R.anim.from_middle, R.anim.to_middle);
finish();
I have searched a lot, everyone says that Android should free up unused memory itself and I shouldn't worry about it, but it seems it's not doing this job in my case!
What should I do?
Upvotes: 1
Views: 74
Reputation: 93542
If it isn't freeing memory eventually, then you probably have a leak. I'd look for objects registered with the OS, async tasks or threads, or anything else that may stay around after the death of the activity that has references back to the activity.
Upvotes: 3