xcode iOS:模拟器中的最大内存?

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

iOS: Maximum memory in simulator?

xcodeios-simulator

提问by Romo

When I start my app in the simulator it crashes immediately with "error: memory read failed"

当我在模拟器中启动我的应用程序时,它立即崩溃并显示“错误:内存读取失败”

Everything works fine on iPad/iPhone, but the when I add a simple "return;" before the core data lines, the simulator starts up fine:

在 iPad/iPhone 上一切正常,但是当我添加一个简单的“返回”时;在核心数据线之前,模拟器启动正常:

return;
CCAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate managedObjectContext];

IMPORTANT!!: It does not run that code at any time, just compiles it. And if I add the "return;" before the same core data connection in another file instead, it runs fine to. Looks like there is some kind of maximum "connection" to core data or something?

重要提示!!:它不会在任何时候运行该代码,只是编译它。如果我添加“返回;” 在另一个文件中使用相同的核心数据连接之前,它运行良好。看起来与核心数据或其他东西有某种最大的“连接”?

I have tried Cleaning Xcode (Normal and clean build folder), cleaning the simulator (Reset content and setting), but with no success.

我曾尝试清理 Xcode(正常和清理构建文件夹),清理模拟器(重置内容和设置),但没有成功。

Additional question: Is there someway I can re-install IOS simulator?

附加问题:有什么办法可以重新安装IOS模拟器吗?

回答by CopperCash

"error: memory read failed". I received same message this morning. And I found it id related to Block.

“错误:内存读取失败”。今天早上我收到了同样的消息。我发现它与 Block 相关。

As we know, if a class has a Block as its member, it ought to be look like this:

我们知道,如果一个类有一个 Block 作为它的成员,它应该是这样的:

@property(nonatomic, copy)BlockType block;

And my mistake was forgot to use copy when add a block to a NSArray instance:

我的错误是在向 NSArray 实例添加块时忘记使用复制:

[array addObject:aBlock];

Finally I solved it by this:

最后我通过这个解决了它:

MyBlockType copy = [aBlock copy];
[array addObject:copy];
[copy release];

Good luck!

祝你好运!

Upate Mar/20/1013 Another situation causes "error: memory read failed".

更新 Mar/20/1013 另一种情况导致“错误:内存读取失败”。

- (void)blockCalledMethod{
    for (BlockType b in _dictionary) {
        b(self);
    }
}

The key to solve my problem is to iterate NSDictionary by using .allKeys. But the object in dictionary is Block, so it must be relative with Block.

解决我的问题的关键是使用 .allKeys 迭代 NSDictionary。但是字典中的对象是Block,所以它必须是与Block相关的。

回答by Kevin ABRIOUX

I have got the same issue with my iPhone simulator. I have clean code in XCode

我的 iPhone 模拟器也有同样的问题。我在 XCode 中有干净的代码

enter image description here

在此处输入图片说明

and i have reset simulator

我已经重置模拟器

enter image description here

在此处输入图片说明

Hope it will help

希望它会有所帮助