首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2ME开发 >

刚看完郭老师的视频,随便编了个,居然出现java.lang.OutOfMemmoryerror解决方案

2012-03-15 
刚看完郭老师的视频,随便编了个,居然出现java.lang.OutOfMemmoryerror哪位大大帮忙看看吧,我的手机是WM的

刚看完郭老师的视频,随便编了个,居然出现java.lang.OutOfMemmoryerror
哪位大大帮忙看看吧,我的手机是WM的系统的,用JAVA模拟器运行报告java.lang.OutOfMemmoryerror错误,可是我在ECLIPS上的模拟器运行正常,在手机的JAVAFX上运行也正常。。。
编译后的JAR文件好像才200多K,我的手机运行1M多的JAVA游戏没问题,不知道哪出错,小弟是JAVA菜鸟级别的人物,望各位大大帮帮忙,先谢谢了~~

Java code
public class LiangZi2 extends MIDlet {    private Display dis;    private MyGameCanvas mgc=new MyGameCanvas();    protected void startApp() throws MIDletStateChangeException {        dis=Display.getDisplay(this);        dis.setCurrent(mgc);            }    class MyGameCanvas extends GameCanvas implements Runnable{        private Image LiangZi,imageYouli;        private TiledLayer BackGroundCanvas;        private Graphics gra;        private LayerManager lm;        private Sprite spriteYouli;        private boolean RUN=true;        public MyGameCanvas(){            super(true);            Mydebug(1);            try            {                LiangZi=Image.createImage("/Img6.jpg");                imageYouli=Image.createImage("/youlishuping.png");                //LiangZi=Image.createImage("/123.gif");                                gra=this.getGraphics();                //spriteZuoquan=new Sprite(zuoquan);                //spriteYouquan=new Sprite(youquan);                spriteYouli=new Sprite(imageYouli,imageYouli.getWidth(),imageYouli.getHeight()/41);                BackGroundCanvas=new TiledLayer(1,1,LiangZi,LiangZi.getWidth(),                        LiangZi.getHeight()/3);                                lm=new LayerManager();                lm.append(BackGroundCanvas);                BackGroundCanvas.setCell(0,0, 1);                //Sleep(3000);            }            catch(Exception   ex){ex.printStackTrace();}            Mydebug(4);            new Thread(this).start();        }                public void run() {            int scrWidth=0,scrHeight=0;            scrWidth=this.getWidth();            scrHeight=this.getHeight();            Mydebug(2);            //spriteZuoquan.setPosition(65,128);            //spriteYouquan.setPosition(195,128);            spriteYouli.setPosition(-80,30);            while (RUN)            {                gra.setColor(0xFFFFFF);                gra.fillRect(0, 0,scrWidth,scrHeight);                lm.paint(gra,0,0);                spriteYouli.paint(gra);                //左右拳显示//                spriteZuoquan.paint(gra);//                spriteYouquan.paint(gra);                this.flushGraphics();                spriteYouli.nextFrame();                try{                    Thread.currentThread();                    Thread.sleep(100);                }catch(Exception ex){System.out.println("Sleep error");}                /*BackGroundCanvas.setCell(0, 0, iNext);                iNext++;                if(iNext>3)                    iNext=1;*/                //Mydebug(iNext);            }        }            }    public void Sleep(long time){        try{            Thread.currentThread();            Thread.sleep(time);        }catch(Exception ex){System.out.println("Sleep error");}    }    protected void Mydebug(int i){            System.out.println("到达"+i);    }    public LiangZi2() {        // TODO Auto-generated constructor stub    }    protected void destroyApp(boolean arg0) throws MIDletStateChangeException {        // TODO Auto-generated method stub    }    protected void pauseApp() {        // TODO Auto-generated method stub    }    }}



[解决办法]
探讨

comment out 不会用
!- -

热点排行