Hi
I have a question that how force to free memory. I put here basic design of my game loop using with only one canvas. Is MIDP 1.0. Next of code my question.
Code:public class MyCanvas extends FullCanvas implements Runnable{ ... public MyCanvas(){ ... menu = new MENU(....); game = new GAME(....); ... } run(){ while(end){ switch(STATE) case MENU: menu.doLogic(); case GAME: game.doLogic(); Repaint(); serviceRepaints(); } } ... paint(Graphics g){ switch(STATE) case MENU: menu.draw(g); case GAME: game.draw(g); }
For example 'menu' load image of background, big image. I want know as can free 'menu' object when STATE are on GAME for free space in memory, because i think that background image for example is too big for have in memory all the time, for obtain more velocity in GAME state. ¿All this is correct?.
I know that in java is GC who free the memory, but as i wrote before, isnt good have data of menu when we are in GAME state.
¿For example this free the memory?
public class MyCanvas
extends FullCanvas implements Runnable{
With this code, ¿are loaded in memory the data of 'menu' when STATE is GAME?.Code:... public MyCanvas(){ ... menu = new MENU(....); ... } run(){ while(end){ switch(STATE) case MENU: if(firstTime){ game=null; menu = new MENU(..); firstTime=false; } menu.doLogic(); break; case GAME: if(firstTime){ menu=null; game = new GAME(..); firstTime=false; } game.doLogic(); break; Repaint(); serviceRepaints(); } } ... paint(Graphics g){ switch(STATE) case MENU: menu.draw(g); case GAME: game.draw(g); }

Reply With Quote


