什么是iOS的常驻和脏记忆? [英] What is resident and dirty memory of iOS?

查看:300
本文介绍了什么是iOS的常驻和脏记忆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我,什么样的记忆是脏的/居住的,它们来自哪里?
常驻内存是否与Mac OS的有线内存相同?

Can some one please tell me, what kind of memory is dirty/resident, and where do they come from? Does resident memory means the same with "wired memory" of Mac OS?

这就是我所看到的Mac OS内存:

this is what I saw about Mac OS memory:


有线:这是指内核代码等。不应该将
的内存移出RAM。也称为常驻内存。

Wired : This refers to kernel code and such. Memory that should not ever be moved out of the RAM. Also know as resident memory.

共享:两个或多个进程共享的内存。两个
进程都会显示这个内存量,所以它可能会有点
误导实际使用的内存量。

Shared : Memory that is shared between two or more processes. Both processes would show this amount of memory so it can be a bit misleading as to how much memory is actually in use.

Real:这是应用程序的实际内存使用量,由task_info()报告
- 粗略计算当前进程的
物理页面数。 (RSIZE)

Real : This is the "real" memory usage for an application as reported by task_info() - a rough count of the number of physical pages that the current process has. (RSIZE)

私有:这是一个进程仅在其驻留内存中使用的自己的
上使用的内存。 (RPRVT)

Private : This is memory that a process is using solely on it's own that is used in Resident memory. (RPRVT)

虚拟:进程中的
映射到任何东西的地址空间总量 - 对于
变量来说这是否是一个任意大的空间或任何东西 - 它不等于实际的VM使用。 (VSIZE)

Virtual : The total amount of address space in the process that's mapped to anything - whether that's an arbitrarily large space for variables or anything - it does not equate to actual VM use. (VSIZE)

活动:当前标记为活动且已使用RAM的内存。

Active : Memory currently labelled as active and is used RAM.

非活动:非活动内存不再被使用,并且已经将
缓存到磁盘。它将保留在RAM中,直到另一个应用程序需要
的空间。如果你需要
(或者你的电脑的客户)稍后回来。 - Mac OS X帮助

Inactive : "Inactive memory is no longer being used and has been cached to disk. It will remain in RAM until another application needs the space. Leaving this information in RAM is to your advantage if you (or a client of your computer) come back to it later." - Mac OS X Help

免费:实际可用的RAM数量,没有任何数据。

Free : The amount of RAM actually available without any data.


推荐答案

这已经快一年了,我想出来了。

It's almost a year and I figured it out.

清理内存

清洁内存是可以重新创建的内存,在iOS上它的内存是:

clean memory are memories that can be recreated, on iOS it is memory of:


  • 系统框架

  • 应用程序的二进制可执行文件

  • 内存映射文件

还要注意这种情况:当你的应用程序链接到框架时,干净的内存将增加框架二进制文件的大小。但大多数时候,只有部分二进制文件真正加载到物理内存中。

Also notice this situation: when your app link to a framework, the clean memory will increase by the size of the framework binary. But most of time, only part of binary is really loaded in physical memory.

脏内存

所有非干净内存的内存都是脏内存,系统无法重新创建脏内存。

All memory that is not clean memory is dirty memory, dirty memory can't be recreated by system.

当存在内存压力时,系统将卸载一些干净的内存,当再次需要内存时,系统将重新创建它们。

When there is a memory pressure, system will unload some clean memory, when the memory is needed again, system will recreate them.

但是对于脏内存,系统无法卸载它们,并且iOS没有交换机制,因此脏内存将始终保存在物理内存中,直到达到某个限制,然后您的应用程序将被终止,系统将回收所有内存。

But for dirty memory, system can't unload them, and iOS has no swap mechanism, so dirty memory will always be kept in physical memory, till it reach a certain limit, then your App will be terminated and all memory for it is recycled by system.

虚拟内存

virtual memory = clean memory + dirty memory.

这意味着虚拟内存是你想要的所有内存。

That means virtual memory is all the memory your App want.

驻留内存

resident memory = dirty memory + clean memory that loaded in physical memory

驻留内存是物理内存中真正加载的内存,它意味着所有脏内存和清洁记忆的一部分。

resident memory is the memory really loaded in your physical memory, it mean all the dirty memory and parts of your clean memory.

结论

任何时候,这都是总是如此:

At any time, this is always true:

virtual memory == (clean memory + dirty memory) > resident memory > dirty memory

如果您担心应用程序正在使用的物理内存(这是您的主要原因)应用程序因内存不足而终止),您应该主要关注驻留内存。

If you are worrying about the physical memory your App is taking(which is the key reason your App is terminated due to low memory), you should mainly focus on resident memory.

这篇关于什么是iOS的常驻和脏记忆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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