Xcode Instruments:在模拟器中运行的 iPhone 应用程序的峰值 RAM?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2153271/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:05:23  来源:igfitidea点击:

Xcode Instruments: peak RAM of iPhone apps running in Simulator?

iphonexcodeios-simulatormemory-managementactivity-monitor

提问by MemoryFoam

Is Activity Monitor (a.k.a. Memory Monitor) the only tool in Xcode Instruments that can measure the total app RAM usage of an iPhone app running in Simulator? Just that line showing momentary wired RAM?

活动监视器(又名内存监视器)是 Xcode Instruments 中唯一可以测量在模拟器中运行的 iPhone 应用程序的应用程序 RAM 总使用量的工具吗?只是显示瞬时有线 RAM 的那条线?

And how accurate is that versus iPhone hardware, especially given OSX paging i/o to VM?

与 iPhone 硬件相比,它的准确度如何,尤其是考虑到 OSX 分页 i/o 到 VM?

I'm seeing 7-8MB wired RAM figures for just the default Xcode iPhone project templates (other than OpenGL) compiled and running. At the same time Object Allocations shows well under 1MB for all objects.

我看到 7-8MB 有线 RAM 数字仅用于编译和运行的默认 Xcode iPhone 项目模板(OpenGL 除外)。同时,对象分配显示所有对象都低于 1MB。

回答by David Kanarek

Nope, there's a much better way to do it.

不,有一个更好的方法来做到这一点。

Go to the Run menu and select Run with Performance Toolthen Object Allocations.

转到运行菜单,Run with Performance Tool然后选择Object Allocations

This will start Instruments and will show RAM usage. It's also useful for detecting memory leaks if you choose Leaksinstead of Object Allocations.

这将启动 Instruments 并显示 RAM 使用情况。如果您选择Leaks代替 ,它也可用于检测内存泄漏Object Allocations

回答by Jazon

I would agree, since the Simulator is just an "API simulator", the behavior you see is going to be at least somewhat dependent how OS X manages memory. And the restrictions are obviously different, for example you can exceed 128 MB of ram, or even 256 MB, which obviously isn't possible on any current iPhone or iPod Touch (at least, as of this writing...).

我同意,因为模拟器只是一个“API 模拟器”,你看到的行为至少在某种程度上取决于 OS X 管理内存的方式。并且限制明显不同,例如您可以超过 128 MB 的内存,甚至 256 MB,这在任何当前的 iPhone 或 iPod Touch 上显然是不可能的(至少,在撰写本文时......)。

I've still found it useful in OpenGL for making sure textures and other items are properly deallocated, but beyond that, it's just a rough guideline.

我仍然发现它在 OpenGL 中很有用,可以确保纹理和其他项目被正确释放,但除此之外,它只是一个粗略的指导方针。

However, if you want to see memory usage on device, there's a simple enough solution. Just target Device in Xcode, and go to Run > Run with Performance Tool > Object Allocations, then the build will be sent to the device and the Object Allocations tool will pop up next to Xcode and show on device memory usage.

但是,如果您想查看设备上的内存使用情况,有一个足够简单的解决方案。只需在 Xcode 中定位设备,然后转到运行 > 使用性能工具运行 > 对象分配,然后构建将发送到设备,对象分配工具将在 Xcode 旁边弹出并显示设备内存使用情况。