简体   繁体   English

Android内存自动清理机制和垃圾收集器触发条件

[英]Android memory automatic cleaning mechanism and garbage collector trigger conditions

I have two problems: 我有两个问题:

1.What is trigger conditions of LOW_MEMORY and OUT_OF_MEMORY in android memory automatic cleaning mechanism? 1.android内存自动清理机制中LOW_MEMORY和OUT_OF_MEMORY的触发条件是什么?

I check the reference LOW_MEMORY is done automatically every once in a while, and OUT_OF_MEMORY is conducted in system out of memory. 我检查参考LOW_MEMORY是否每隔一段时间自动完成一次,并且OUT_OF_MEMORY在内存不足的系统中进行。 Is this right? 这是正确的吗? If it is right, is the recovery of memory strategy the same? 如果正确,那么恢复存储策略是否一样?

2.What conditions perform memory of the recovery in android task manager? 2.什么条件在android任务管理器中执行恢复的内存?

The detail condition is testing phone memory 512; 详细条件是测试电话存储器512; the user available memory is 230. The visual inspection is 50M. 用户可用内存为230。外观检查为50M。 It can trigger the memory recall in 20M. 它可以触发20M的内存调用。 That is to say 50M and 20M are the stable memory. 也就是说50M和20M是稳定的内存。 But sometimes it has not the trigger recycle when the memory less than 3M. 但是有时当内存少于3M时它不会触发回收。 Is the trigger recycle need special condition? 扳机回收是否需要特殊条件? Where the trigger recycle code should be put? 触发器回收代码应该放在哪里?

In android is each application has fixed memory limit.. it change from device to device... for ex if phone memory is 512.. and app memory will be 30 to 50 mb if your app cross using this memory it will get crash... 在android中,每个应用程序都有固定的内存限制..它会因设备而异...例如,如果手机内存为512 ..并且应用程序内存将为30到50 mb,如果您的应用程序使用此内存将崩溃。 ..

onLowMemory is the method in the activity.. it notifier when memory is low... it is like warning .. OUT_OF_MEMORY is exception which you cant handle(catch).. onLowMemory是活动中的方法。.当内存不足时通知。。。就像警告.. OUT_OF_MEMORY是您无法处理(捕获)的异常。
OUT_OF_MEMORY exception max raise normally when we deal with bitmap... 当我们处理位图时,OUT_OF_MEMORY异常max通常会引发。

Garbage collector is available in android also but when we deal with bitmaps it may fail in some cases.. for bitmap we are responsible to recycle.. 垃圾收集器在android中也可用,但是当我们处理位图时,在某些情况下它可能会失败..对于位图,我们负责回收。

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

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