So, I tested my game out for the first time with the Monkey test. I managed to go about 3 minutes without a crash, but I ended up crashing with an out of memory error, and I'm trying to figure out how I might make it better.
My program is structured as follows:
- There is a front screen which will start an activity.
- The secondary activity is where most of the action is, and also where I crashed.
- I crash on an inflate command
- My game forces portrait mode, it was easier to make 1 layout than 2 work...
- There are a number of class variables associated with my secondary activity. I'll include the non-static ones below. I've also included some kind of a clue for those things which aren't obvious as to what they are.
What I'm wanting to know is how I can improve the memory management of my program so it won't crash. I suspect that I need to manually delete some of these variables, but I'm not sure what the right place to do so is. Thanks!
private Level_Score_bar score_bar; // Custom view
private number_viewer num_viewer; // Custom view
private number_pad num_pad; // Custom View
private int time,score,level,num_remaining,current_var,change_loc,time_remaining;
private ArrayList<Integer> the_key;
private ImageView Number_to_select;
private Boolean update_viewer;
Random rseed;
Vibrator bzzz;
long ctime;
private Activity self=this;
private SharedPreferences prefs;
private Editor prefs_edit;
The out of memory occurred
setContentView(R.layout.level_layout);
This layout is rather complex, containing several image views, buttons, text views, etc.