简体   繁体   English

如何销毁libgdx中的应用程序侦听器对象

[英]How to destroy Application listener object in libgdx

I am using libgdx, my code is like this, 我正在使用libgdx,我的代码是这样的,

public class MyActivity extends AndroidApplication {

    public void onCreate(Bundle savedInstanceState){
    //here i have initialized my application listener object
    initialize(new MyApplicationListener(),false);
    //other code
    }
}

//MyApplicationListener.java
public class MyApplicationListener implements ApplicationListener {

    public void create(){}
    public void render(){}
    public void dispose() {
        //diposing all resources
    }
}

Now my question is when iam finishing my MyActivity.java , the dispose() -method in MyApplicationListener.java was not getting called. 现在我的问题是,当我完成MyActivity.java ,没有调用MyApplicationListener.javadispose()方法。 Therefore my game was affecting from OOM exception.I have also tried to call the dispose method manually, but few objects were remaining as it is in the heap. 因此,我的游戏受到了OOM异常的影响。我也尝试过手动调用dispose方法,但是很少有对象保留在堆中。

To start from scratch, open the gdx-setup-ui.jar from the downloaded libGDx zip folder. 从点滴做起,从打开下载的libGDx的zip文件夹中的GDX-设置-ui.jar。 Export the created three project folders to Eclipse. 将创建的三个项目文件夹导出到Eclipse。 Use it as reference to find out how to run it. 使用它作为参考来了解如何运行它。 See instructions for details on how to use this jar file. 请参阅有关如何使用这个jar文件的详细说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM