Xcode iPhone构建失败,内存不足

时间:2021-05-29 23:01:57

Sometimes the project compiles, and sometimes it fails with

项目有时会编译,有时会失败

"Out of memory allocating 4072 bytes after a total of 0 bytes"

“在总共0字节后分配4072字节内存不足”

If the project does compile, when it starts it immediately throws a bad access exception when attempting to access the first (allocated and retained) object, or, throws an error "unable to access memory address xxxxxxxx", where xxxxxxxx is a valid memory address.

如果项目进行了编译,当它启动时,当试图访问第一个(分配和保留)对象时,它会立即抛出一个错误的访问异常,或者抛出一个错误“无法访问内存地址xxxxxxxxxx”,其中xxxxxxxx是一个有效的内存地址。

Has anyone seen similar symptoms and knows of workarounds?

有谁见过类似的症状,知道解决方法吗?

Thanks in advance.

提前谢谢。

2 个解决方案

#1


2  

If compilation or linking is failing with an out of memory error like that, it is likely one of two issues.

如果编译或链接出现类似的内存不足错误,这可能是两个问题之一。

First, does your boot drive or the drive that you are building your source on have free space (they may be the same drive)? If not, then that error may arise when the VM subsystem tries to map in a file or, more likely if boot drive is full, the VM subsystem tries to allocate more drive for swap space.

首先,您正在构建源代码的引导驱动器或驱动器是否有空闲空间(它们可能是相同的驱动器)?如果不是,那么当VM子系统试图在文件中映射时,可能会出现错误,或者如果引导驱动器已满,那么VM子系统试图为交换空间分配更多的驱动器。

Secondly, is your application just absolutely gigantic? I.e. is it the linker that is failing as it tries to assemble something really really large?

第二,你的应用程序真的非常庞大吗?也就是说,链接器失败了吗因为它试图组装一个非常大的东西?

There is also the possibility that the system has some bad RAM in it. Unlikely, though, given that the symptoms are so consistent.

也有可能系统中有一些坏RAM。然而,考虑到这些症状是如此一致,这种可能性不大。

In any case, without more details, it is hard to give a more specific answer.

无论如何,没有更多的细节,很难给出一个更具体的答案。

#2


0  

I've seen this, it is not usually an actual memory error...(of your code)

我见过这个,它通常不是一个实际的内存错误……(代码)

what is happening is that you have your Xcode target Build settings "optimization level" set to Fast, or faster, or fastest..

现在的情况是,您的Xcode目标构建设置“优化级别”设置为快、快或最快。

there appears to be a bug in there somewhere, set it to none, or try the Os, or O3 (i don't think fastest is effected)..

这里似乎有一个bug,将其设置为none,或者尝试使用Os或O3(我认为影响最快的是不存在的)。

this will very likely solve someones problem that comes across this thread. for sure try "none" first... this will confirm that this is what is happening in someone's case that sees this...

这很可能会解决遇到的一些问题。当然,要先尝试“无”……这将证实这是发生在看到这个的人身上的事情。

i can tell that McPragma is having this problem for sure, because he/she describes changing from debug to release, and this causes it (debug is already set to none) and release is set to something else... when that is the case... for sure it is that particular build setting...

我可以肯定地说,McPragma有这个问题,因为他/她描述了从调试到发布的变化,这导致了(debug已经设置为none),而release设置为其他的东西……在这种情况下……肯定是那个特定的构建设置……

#1


2  

If compilation or linking is failing with an out of memory error like that, it is likely one of two issues.

如果编译或链接出现类似的内存不足错误,这可能是两个问题之一。

First, does your boot drive or the drive that you are building your source on have free space (they may be the same drive)? If not, then that error may arise when the VM subsystem tries to map in a file or, more likely if boot drive is full, the VM subsystem tries to allocate more drive for swap space.

首先,您正在构建源代码的引导驱动器或驱动器是否有空闲空间(它们可能是相同的驱动器)?如果不是,那么当VM子系统试图在文件中映射时,可能会出现错误,或者如果引导驱动器已满,那么VM子系统试图为交换空间分配更多的驱动器。

Secondly, is your application just absolutely gigantic? I.e. is it the linker that is failing as it tries to assemble something really really large?

第二,你的应用程序真的非常庞大吗?也就是说,链接器失败了吗因为它试图组装一个非常大的东西?

There is also the possibility that the system has some bad RAM in it. Unlikely, though, given that the symptoms are so consistent.

也有可能系统中有一些坏RAM。然而,考虑到这些症状是如此一致,这种可能性不大。

In any case, without more details, it is hard to give a more specific answer.

无论如何,没有更多的细节,很难给出一个更具体的答案。

#2


0  

I've seen this, it is not usually an actual memory error...(of your code)

我见过这个,它通常不是一个实际的内存错误……(代码)

what is happening is that you have your Xcode target Build settings "optimization level" set to Fast, or faster, or fastest..

现在的情况是,您的Xcode目标构建设置“优化级别”设置为快、快或最快。

there appears to be a bug in there somewhere, set it to none, or try the Os, or O3 (i don't think fastest is effected)..

这里似乎有一个bug,将其设置为none,或者尝试使用Os或O3(我认为影响最快的是不存在的)。

this will very likely solve someones problem that comes across this thread. for sure try "none" first... this will confirm that this is what is happening in someone's case that sees this...

这很可能会解决遇到的一些问题。当然,要先尝试“无”……这将证实这是发生在看到这个的人身上的事情。

i can tell that McPragma is having this problem for sure, because he/she describes changing from debug to release, and this causes it (debug is already set to none) and release is set to something else... when that is the case... for sure it is that particular build setting...

我可以肯定地说,McPragma有这个问题,因为他/她描述了从调试到发布的变化,这导致了(debug已经设置为none),而release设置为其他的东西……在这种情况下……肯定是那个特定的构建设置……