Xcode 4 变得非常慢并且杀死了我的硬盘
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6225603/
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
Xcode 4 became extremely slow and kills my hard drive
提问by Lukasz
My machine has 8 GB or RAM, Core 2 Duo 3,06 GHZ and it seems it is not enough for Xcode 4 (4.0.1). From some time now it started to behave more and more slow. Auto completion, editing code as well as Xib files became almost impossible to use.
我的机器有 8 GB 或 RAM,Core 2 Duo 3,06 GHZ,对于 Xcode 4 (4.0.1) 似乎还不够。从现在开始,它开始表现得越来越慢。自动完成、编辑代码以及 Xib 文件变得几乎无法使用。
Other applications behave smoothly.
其他应用程序运行平稳。
Activity monitor shows a lot of RAM usage (still few GB left of completely free memory, so it is quite OK) and huge disk activity usage. I can see on the graph high peaks of data being saved periodically when I work in Xcode. After 3 hours of work there is 10.5 GB of data written to the disk. Is it normal?
活动监视器显示大量 RAM 使用量(完全可用内存还剩下几 GB,所以它很不错)和巨大的磁盘活动使用量。当我在 Xcode 中工作时,我可以在图表上看到定期保存的数据高峰。工作 3 小时后,有 10.5 GB 的数据写入磁盘。正常吗?
I have tried to disable auto-save but it did not help much.
我试图禁用自动保存,但它没有多大帮助。
What can be the other causes of this extremely slow behavior of Xcode 4?
Xcode 4 这种极其缓慢的行为的其他原因是什么?
It did not behave like this from the beginning and it is not during Xcode indexing.To be even more interesting: when Xcode is indexing my project after cleaning it takes less CPU power than when indexing is done (CPU raises up after indexing again). Heh?
它从一开始就没有这样的行为,也不是在 Xcode 索引期间。更有趣的是:当 Xcode 在清理后索引我的项目时,它比完成索引时占用更少的 CPU 功率(CPU 在再次索引后上升)。呵?
UPDATE:Complete reinstall of Snow Leopard (to the cleaned disk) together with Xcode did not help much. Xcode was working quite well just for a day or so and then slowed down again to the degree it is hardly possible to work with.
更新:用 Xcode 完全重新安装 Snow Leopard(到清理过的磁盘)并没有多大帮助。Xcode 运行良好仅一天左右,然后又变慢到几乎无法使用的程度。
采纳答案by Lukasz
UPDATE:
更新:
The solution was to mock around with #import "header.h"
statements. It looks like Xcode requires a lot of processing power for intellisense when you you have complicated / circular imports structure (tracked down by performance tools - Xcode was falling into infinite recursive function call loop). When I moved as many imports I could to the implementation files and used forward declarations in headers, the problem went away.
解决方案是用#import"header.h"
语句来模拟。当您具有复杂的/循环导入结构(由性能工具跟踪 - Xcode 陷入无限递归函数调用循环)时,看起来 Xcode 需要大量的智能感知处理能力。当我将尽可能多的导入移动到实现文件并在标题中使用前向声明时,问题就消失了。
This is what I have tried before:
这是我之前尝试过的:
- Reinstalling (complete removal by: sudo /Developer/Library/uninstall-devtools –mode=al) and installed new version 4.0.2 - Did NOT help at all. Anyway - Is it really complete removal as my main custom Xcode preference settings has survived)?
- Defragmentation (iDefrag - full defragmentation with rebuiling B-Tree and Metadata) - Did NOT help at all.
- System cleaning and antivirus scanning - CleanMyMac, MacKeeper - did NOT help at all.
- Organizer - Repositories - cleaned all repositories (I use Git and Xcode somehow stores list there for its own reasons even if I use only command line to manage Git) - small improvement.
- Organizer - Projects - cleaned all Projects from the list except opened ones - small improvement
- File - Source control - disable Show Remote Status (was enabled somehow, thx to ThomasW for pointing to that), but did NOT help much.
- Xcode - Preference - General - Disable Auto-Save (prompt only) and both Live Issues (In Editors, In Issue Navigator) - quite a bit of improvement.
- Closed Utility Panel and Quick Help Pane - the biggest improvement!. I can finally type smoothly again! What a surprise. Such a trivial solution. It looks like help indexing / search assistant simply sucks! Why it does not do lookups in the background or something?
- 重新安装(完全删除:sudo /Developer/Library/uninstall-devtools –mode=al)并安装新版本 4.0.2 - 根本没有帮助。无论如何 - 因为我的主要自定义 Xcode 首选项设置仍然存在,所以它真的完全删除了吗)?
- 碎片整理(iDefrag - 重新构建 B 树和元数据的完整碎片整理)- 根本没有帮助。
- 系统清理和防病毒扫描 - CleanMyMac、MacKeeper - 根本没有帮助。
- 组织者 - 存储库 - 清理所有存储库(我使用 Git 和 Xcode 以某种方式将列表存储在那里,即使我只使用命令行来管理 Git) - 小的改进。
- 组织者 - 项目 - 从列表中清除所有项目,除了打开的项目 - 小改进
- 文件 - 源代码控制 - 禁用显示远程状态(以某种方式启用,感谢 ThomasW 指出该状态),但没有太大帮助。
- Xcode - Preference - General - Disable Auto-Save (prompt only) and both Live Issues (In Editors, In Issue Navigator) -相当多的改进。
- 关闭实用程序面板和快速帮助面板 - 最大的改进!. 终于可以流畅的打字了!真是个惊喜。这样一个微不足道的解决方案。看起来帮助索引/搜索助手简直糟透了!为什么它不在后台进行查找之类的?
Xcode is still slow but now it is almost possible to work with production quality performance. Anyway it is quite a shame that Core 2 Duo 3,06Ghz / 8BG DDRIII Ram / Momentus XT SS Hybrid can hardly make it. I was so close to buy OCZ Vertex SSD or some other super extra SSD because of this.
Xcode 仍然很慢,但现在几乎可以使用生产质量性能。无论如何,Core 2 Duo 3,06Ghz / 8BG DDRIII Ram / Momentus XT SS Hybrid 很难做到,这真是太遗憾了。因此,我非常想购买 OCZ Vertex SSD 或其他一些超级额外的 SSD。
回答by ThomasW
I was running into performance problems with Xcode 4 and I tracked it down to the File->Source Control->Show Remote Status feature being on. Turning that feature off did the trick for me.
我在使用 Xcode 4 时遇到了性能问题,我将其追踪到 File->Source Control->Show Remote Status 功能。关闭该功能对我来说很有效。
However, if that is not the issue then you should take samples of Xcode while it is having the performance issues. Either use the command line or the Activity Monitor application. This might give you a clue as to what the issue is. If it doesn't then post the sample here. Also, submit a bug to Apple with the sample.
但是,如果这不是问题,那么您应该在 Xcode 出现性能问题时获取它的样本。使用命令行或活动监视器应用程序。这可能会为您提供有关问题所在的线索。如果没有,则在此处发布示例。此外,将错误与示例一起提交给 Apple。
回答by kris
The following helped me A LOT - purge the workspace file.
以下帮助了我很多 - 清除工作区文件。
I didn't download the applet they're talking about but just manually doing it is working very effectively so far...
我没有下载他们正在谈论的小程序,但只是手动执行它到目前为止工作非常有效......
[Update: corrected the link]
[更新:更正链接]
回答by OfficerDave
For me, Storyboard was almost unusable until I clicked on the View Controller and then "Editor - Resolve AutoLayout Issues - Clear All Constraints in View Controller".
对我来说,故事板几乎无法使用,直到我单击视图控制器,然后单击“编辑器 - 解决自动布局问题 - 清除视图控制器中的所有约束”。
I had been trying to fix layout issues and was also toggling the [3.5" / 4" Retina] button in the constraint tool bar (lower-right of the Storyboard window).
我一直在尝试修复布局问题,并在约束工具栏(故事板窗口的右下角)中切换 [3.5" / 4" Retina] 按钮。
Once I cleared this, Xcode performance was back to 100%.
一旦我清除了这一点,Xcode 的性能就会恢复到 100%。
回答by drekka
No this is not normal. I use a MAcbook Pro and it works quite normally, not sucking any more RAM than any other app. Occasionally it chews some CPU and RAM, but s restart and it's back to behaving. I put that down to XCode 4 still being quite new after the rebuild.
不,这不正常。我使用的是 MACbook Pro,它工作正常,不会比任何其他应用程序占用更多的内存。有时它会占用一些 CPU 和 RAM,但会重新启动并恢复正常。我把这归结为重建后 XCode 4 仍然很新。
If you are getting this sort of behavior, I'd suggest completely uninstalling XCode and all developer tools. Make sure you get the SDKs and everything out. Reboot. Then reinstall and see if it improves.
如果您遇到这种行为,我建议您完全卸载 XCode 和所有开发人员工具。确保你得到了 SDK 和所有东西。重启。然后重新安装看看是否有改善。
Oh, and I use Git for all my projects.
哦,我所有的项目都使用 Git。