如何解决内存不足问题 [英] How to resolve out of memory issue

查看:119
本文介绍了如何解决内存不足问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友我是其中含有这么多的图像和animations.Due一个应用程序的工作到运行该应用程序2,3次会自动崩溃和日志猫显示内存不足的问题了。会有什么解决办法吗?

Friends i am working on a application which containing so many images and animations.Due to which after running the application 2,3 times it is crashing automatically and the log cat is showing out of memory issue. What will be the solution?

推荐答案

这将是最好创建一个扩展应用程序的类。
每当应用程序进入低内存这个应用程序类将给你onlowmemory()回调。
在那里你可以写

It would be best to create a class that extends Application . This application class will give you onlowmemory() callback whenever application goes low memory. on there you can write

public void onLowmemory()
{
          Runtime.getRuntime().gc();
}

将调用系统气相色谱法。在执行垃圾收集Android将垃圾全部未使用的对象。

which will invoke system GC method. Upon executing garbage collector android will garbage all unused objects.

有另一种方法来解决这个问题。在动画你可以调用调用Runtime.getRuntime()GC()。
调用垃圾收集器。也是在活动的onDestroy()方法ü可以调用调用Runtime.getRuntime()GC()。

There is another way to solve this problem. In animation you can call Runtime.getRuntime().gc(); to invoke garbage collector. also in activity onDestroy() method u can call Runtime.getRuntime().gc();

所以你的问题将得到解决。

so your problem will be solved

这篇关于如何解决内存不足问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆