增加代码缓存容量没有结束



在运行时,我将其在我的Android监视器中得到,它不断扩展,没有目的:

09-02 14:01:36.150 25666-25671/... I/zygote: Do partial code cache collection, code=30KB, data=27KB
09-02 14:01:36.150 25666-25671/... I/zygote: After code cache collection, code=30KB, data=27KB
09-02 14:01:36.151 25666-25671/... I/zygote: Increasing code cache capacity to 128KB
09-02 14:01:39.064 25666-25671/... I/zygote: Do partial code cache collection, code=59KB, data=53KB
09-02 14:01:39.066 25666-25671/...r I/zygote: After code cache collection, code=59KB, data=53KB
09-02 14:01:39.066 25666-25671/... I/zygote: Increasing code cache capacity to 256KB
09-02 14:01:46.287 25666-25671/... I/zygote: Do full code cache collection, code=123KB, data=94KB
09-02 14:01:46.298 25666-25671/... I/zygote: After code cache collection, code=97KB, data=59KB
09-02 14:01:53.853 25666-25671/... I/zygote: Do partial code cache collection, code=122KB, data=90KB
09-02 14:01:53.853 25666-25671/... I/zygote: After code cache collection, code=122KB, data=90KB
09-02 14:01:53.853 25666-25671/... I/zygote: Increasing code cache capacity to 512KB

这是代码:

CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
for (int i = 0; i < IDs.size(); i++) {
    InputStream inputStream = new URL("https://awebsite/" + IDs.get(i)).openStream();
    inputStream.close();
}

问题"固定",它在真实的设备上工作,但在模拟的设备上不起作用。

可以在官方文档中找到答案:

https://developer.android.com/topic/performance/memory-overview

Android Runtime(ART)和Dalvik虚拟机使用分页和内存映射(映射)来管理内存。这意味着应用程序的任何内存都可以修改(无论是通过分配新对象还是触摸映射的页面)将驻留在RAM中,并且无法分类。从应用程序发布内存的唯一方法是发布该应用程序保留的对象引用,使内存可用于垃圾收集器。

垃圾收集

托管内存环境,例如艺术或Dalvik虚拟机跟踪每个内存分配。

在虚拟机中,它正在发生,但是在物理设备中,结果是不同的。垃圾收集器清洁或需要清洁不再使用的任何东西。

相关内容

最新更新