We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当内存一直增加,resident_size会停留在一个最大值(这个最大值会比resident_size_max小一点),然后不在增加.所以这个resident_size并不能真的代表app使用的内存.
用resident_size 去获取app的使用内存是不准确的.
The text was updated successfully, but these errors were encountered:
@laughingkid 是的,resident_size 确实获取不到准确的内存,正确的方式是使用 phys_footprint,这个从 WebKit 和 XNU 的源码都能够得到佐证。WebKit 代码
resident_size
phys_footprint
size_t memoryFootprint() { task_vm_info_data_t vmInfo; mach_msg_type_number_t count = TASK_VM_INFO_COUNT; kern_return_t result = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count); if (result != KERN_SUCCESS) return 0; return static_cast<size_t>(vmInfo.phys_footprint); }
XNU 代码 中 Jetsam 中判断应用内存是否过大使用的也是 phys_footprint,2018 WWDC Session iOS Memory Deep Dive 对这块也有介绍,有兴趣可以去看下。
Sorry, something went wrong.
详细的讨论过程见这个 Issue-获取 App 内存不准
aozhimin
No branches or pull requests
当内存一直增加,resident_size会停留在一个最大值(这个最大值会比resident_size_max小一点),然后不在增加.所以这个resident_size并不能真的代表app使用的内存.
用resident_size 去获取app的使用内存是不准确的.
The text was updated successfully, but these errors were encountered: