Xcode Instruments 使用大量内存。
好的,这是我的问题,如果重复,我深表歉意。我进行了搜索,但找不到任何我认为相关的内容。
当我从 xcode 运行仪器并开始测试我的应用程序是否存在内存泄漏或分配时,我的 iMac 最终开始运行得非常非常慢。
这导致我在使用仪器时运行活动监视器,我注意到每打开第二个仪器就会占用越来越多的实际内存。每秒大约 100MB。
没过多久,它就耗尽了我所有 iMac 的可用内存(2GB),然后就开始滞后。
无论如何,并不是每个应用程序都会发生这种情况。我对我下载的一些应用程序/项目做了同样的测试,仪器似乎只使用了大约 250mbs 的空间,并且没有显着增加。
有什么明显的事情我做错了吗?任何帮助将不胜感激。
谢谢。
Okay so this is my issue and I apologize if its a duplicate. I searched but couldn't find anything I considered relevant.
When I run instruments from xcode and begin testing my application for memory leaks or allocations my iMac eventually begins to run very very slowly.
This caused me to run activity monitor while using instruments and I notice that every second instruments is open it takes up more and more real memory. Roughly 100MB's a sec.
It doesn't take long for it to consume all my iMacs free memory (2gbs) and then it starts to lag.
Anyways this doesn't occur with every application. I've done the same test with some application/projects I downloaded and instruments only seems to use about 250mbs of space and doesn't dramatically increase.
Is there something obvious that I'm doing incorrectly? Any help would be appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仪器消耗大量内存。
根据您录制的内容,您可以减少其内存使用量。例如,您通常可以指定要记录什么(或不记录什么),或降低采样频率(如果适用)。
100MB/s 是异常高的。你能更准确地描述一下你当时录制的内容吗? (您使用的仪器、您录制的过程正在做什么等)。
Xcode 3 使用的内存少得多 - 不确定 Instruments 是否也是如此。
您可以通过将工具集作为 32 位进程运行来稍微减少内存使用量。
最后,2GB 物理内存对于 Xcode + Instruments + iOS Sim 来说根本不算什么。 fwiw,我经常耗尽 8 GB 或更多 GB 的物理内存。嘘。幸运的是,当您想要 4 或 8GB 的内存时,内存很便宜。
更新
如果必须的话,您可以单独运行这些测试。
分配
如果您的应用没有创建大量分配,则分配本身不应消耗大量内存。
要减少此工具的内存,您可以禁用一些您不感兴趣的选项:
泄漏
泄漏检测本身可能会消耗大量内存,因为它会扫描内存,基本上是克隆您的分配。假设您分配了 100MB - 泄漏将定期暂停进程、克隆内存并扫描其模式。这可能比您的应用程序消耗更多的内存。 iirc,它作为 Instruments 中的子进程执行。
僵尸
僵尸检测通常意味着引用计数记录。调试僵尸时,最有效的方法是永远不要释放它们。如果你释放它们,你可能只会检测到短暂的僵尸(不确定仪器中是否有选项......)。从不释放 objc 分配显然会消耗更多内存。在进程上运行泄漏将消耗更多内存,因为堆大小会更大 - 不应将泄漏和僵尸结合起来。
您应该能够通过禁用其中一些选项并单独测试它们来减少总消耗。
注释
祝你好运
instruments consumes a lot of memory.
depending on what you are recording, you may reduce its memory usage. for example, you can often specify what (or what not) to record, or lower sampling frequencies(if applicable).
100MB/s is unusually high. can you give a more exact description of what you are recording in that time? (instruments you use, what the process you record is doing, etc).
Xcode 3 used a lot less memory - not sure if that's also the case for Instruments.
You can reduce the memory usage somewhat by running the toolset as 32 bit processes.
lastly, 2GB physical memory is nothing for Xcode + Instruments + iOS Sim. fwiw, i regularly exhaust physical memory with 8 or more GB. boo. fortunately, memory is cheap when you want 4 or 8GB.
Update
You can run these tests individually, if you must.
Allocations
By itself, allocations should not consume a ton of memory if your app is not creating a lot of allocations.
To reduce memory with this instrument, you can disable some options you are not interested in:
Leaks
Leaks detection itself can consume a lot of memory because it scans memory, basically cloning your allocations. say you have 100MB allocated - leaks will periodically pause the process, clone the memory and scan it for patterns. this could consume more memory than your app. iirc, it's executed as a subprocess in instruments.
Zombies
Zombie detection usually implies ref count recording. When debugging zombies, it's most effective to never free them. If you do free them, you may only detect transient zombies (not sure if there's an option for that in instruments...). Never freeing objc allocations will obviously consume more memory. Running leaks on a process will then consume more memory because your heap sizes will be larger - leaks and zombies should not be combined.
you should be able to reduce total consumption by disabling some of these options and testing for them individually.
Notes
good luck