Xcode 5 - 失控的 CPU 和内存使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19014559/
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-15 03:55:08  来源:igfitidea点击:

Xcode 5 - out of control CPU and memory usage

iosxcode

提问by Andrew Kozlik

I've been having issues lately with the latest version of Xcode 5. About a minute or so after launching CPU usage and Real Memory usage skyrocket. I've seen CPU usage as high as 400% and RAM usage as high as 13GB.

我最近在使用最新版本的 Xcode 5 时遇到了问题。在启动 CPU 使用率和实内存使用率飙升后大约一分钟左右。我见过 CPU 使用率高达 400%,RAM 使用率高达 13GB。

I'm on an i5 iMac with 16GB of RAM.

我使用的是配备 16GB RAM 的 i5 iMac。

I've tried uninstalling Xcode and reinstalling, running all Mountain Lion upgrades, fixing recurring header loops, launching Xcode without indexing and a few other issues all to no avail. I'm now at a loss as to what I can do.

我试过卸载 Xcode 并重新安装、运行所有 Mountain Lion 升级、修复重复出现的标题循环、在没有索引的情况下启动 Xcode 以及其他一些问题都无济于事。我现在不知我能做什么。

Activity Monitor after running Xcode for a few minutes. No compiles or anything

运行 Xcode 几分钟后的活动监视器。 没有编译或任何东西

I would love suggestions of things to try. I've tried running my project on other i5 iMacs and I don't have this issue.

我很想尝试一些建议。我试过在其他 i5 iMac 上运行我的项目,但我没有这个问题。

Thanks everyone.

谢谢大家。

采纳答案by tonytastic

I had this exact problem over the weekend with my Macbook Air and Xcode5. I tired resetting Xcode back to default, deleting the iOS simulator files, etc.

周末我的 Macbook Air 和 Xcode5 遇到了这个问题。我厌倦了将 Xcode 重置回默认值、删除 iOS 模拟器文件等。

I've isolated it to it being the Source Control functionality in XCode. The high CPU usage doesn't seem to happen when the affected Project is not open, (Close everything and start a new Xcode project). I've disabled Source Control within XCode and and started using GitX instead, and CPU levels for XCode has dropped back to normal levels (5 - 15%).

我已经将它与 XCode 中的源代码控制功能隔离开来。当受影响的项目未打开时,似乎不会出现高 CPU 使用率(关闭所有内容并启动一个新的 Xcode 项目)。我在 XCode 中禁用了源代码控制,并开始使用 GitX,而 XCode 的 CPU 水平已回落到正常水平(5 - 15%)。

I haven't dug deeper into XCode to see what could have triggered it.

我还没有深入研究 XCode,看看是什么触发了它。

回答by Roy Lovejoy

I was running at 120% - beachball almost constantly - while idle.

我以 120% 的速度跑 - 沙滩球几乎一直在 - 空闲时。

What dropped me down to 1.3% was unchecking "Refresh local status automatically" in the "Source Control" tab in Xcode Preferences.

使我下降到 1.3% 的是在 Xcode 首选项的“源代码控制”选项卡中取消选中“自动刷新本地状态”。

You can still have "Enable Source Control" and "Refresh Server Status Automatically" and "Add and remove files automatically"

您仍然可以拥有“启用源代码控制”和“自动刷新服务器状态”以及“自动添加和删除文件”

回答by Sam Bavi

I just experienced similar issues with xcode after an update yesterday.

昨天更新后,我刚刚在 xcode 上遇到了类似的问题。

My memory on a 16GB macbook pro just dried out every time I opened xcode from 11-12gb of free ram to somewhere between 3-4gb with or without any projects open. I tried deleting the DerivedData folder to no avail.

每次我打开 xcode 从 11-12gb 的空闲内存到 3-4gb 之间的某个位置时,无论是否打开任何项目,我在 16GB macbook pro 上的内存都会变干。我尝试删除 DerivedData 文件夹无济于事。

The only solution that I have found that fixes the issue temporarily is for me to let xcode eat all the memory after starting and then doing a sudo purgein terminal.

我发现暂时解决问题的唯一解决方案是让 xcode 在启动后吃掉所有内存,然后sudo purge在终端中执行。

After the purge I can work as normal with xcode with any projects using only as much ram as it needs to, but this needs to be done every time I start xcode.

清除后,我可以像往常一样使用 xcode,任何项目只使用它需要的内存,但是每次启动 xcode 时都需要这样做。

回答by Mark McCorkle

I've submitted a couple bug reports regarding this and while debugging it we came to a conclusion it seems to happen with upgraded projects. By simply removing all the classes from my project then reading them I no longer experience the horrible cpu usage and ram usage. This was primarily happening on 5.0 with my storyboards prior to simply removing them and re-adding them to the project. Xcode 5.0.1 also helped my performance.

我已经提交了一些关于此的错误报告,在调试它时我们得出结论,它似乎发生在升级的项目中。通过简单地从我的项目中删除所有类然后阅读它们,我不再经历可怕的 cpu 使用和 ram 使用。这主要发生在 5.0 上,我的故事板在简单地删除它们并将它们重新添加到项目之前。Xcode 5.0.1 也帮助了我的表现。

*UPDATE Since updating to Xcode 5.0.2 I no longer see these issues. I can finally work on large storyboards again.

*更新自从更新到 Xcode 5.0.2 我不再看到这些问题。我终于可以再次制作大型故事板了。

回答by anoop4real

I have actually figured out the cause of this memory issue in the source that I have, it was because one of the 3rd party library used was giving a lot of warnings and may be xcode is trying to do some processing around that. Just for test purpose, I removed the library and some of the classes which used that, and I was able to build the code faster. Now I plan to get to the bottom of the warnings and try to fix it. Not sure if all the people facing these issue is because of this but this was definitely the reason for my problem.

我实际上已经在我拥有的源代码中找出了这个内存问题的原因,这是因为使用的第 3 方库之一给出了很多警告,并且可能是 xcode 试图对此进行一些处理。只是为了测试目的,我删除了库和一些使用它的类,并且我能够更快地构建代码。现在我计划深入了解警告并尝试修复它。不确定是否所有面临这些问题的人都是因为这个,但这绝对是我的问题的原因。

回答by Charana STR

Did you try to access many libraries at the same time or did you run a search trough out the system regarding a Xcode file or a project?This could sometimes bring the issue you have.running so many functions in xcode at the same time can bring these type of problems.if you can reinstall xcode after taking a backup of the data you need.

您是否尝试同时访问多个库,或者您是否在系统中搜索过有关 Xcode 文件或项目的信息?这有时会带来您遇到的问题。同时在 xcode 中运行这么多函数可能会带来这些类型的问题。如果您可以在备份您需要的数据后重新安装 xcode。