NSError
NSError

Reputation: 175

iOS app runs normally in debug mode but crashed in normal mode

Summary: I'm developing an app. The strange thing is when I run it in debug mode(connect my device to Xcode and click run button), it acts normally. But when I run it in normal mode(Without connecting it to Xcode, open it normally like what a user will do), it crashed.

Solution: please see the answer by @skyline75489 below, his answer saved my day! When you encounter this problem, try to reduce the size of the images. Details:

Now I'm developing an iOS8 keyboard. In the init of the keyboard, there's something that seems to take a lot of memory. I think it's not the problem of the extension, it's the problem of the memory or setting.

for (int i = 0; i<=numberOfImagesInCurrentArray; i++) {
    UIImage *image = [UIImage imageWithContentsOfFile:[currentPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%i.png",i]]];
    if (image) {
        [convertedArray addObject:image];

    }
}

Now the problem is when I'm in debug mode(When I connect my device to Mac and run the extension, and attach the extension to "Message" app), the extension runs perfectly even if the array contains 30 images. (takes 40M memory)

But when I run it in normal mode(open "Message", and click on the textfield), the extension crashed with only 15 images in that array, but when there're only about 10 images, it doesn't crash.

My question is : is this issue caused by memory issue? Or I set something wrong in the info.plist that causes the differences in debug mode?

Upvotes: 0

Views: 629

Answers (1)

ljk321
ljk321

Reputation: 16770

I've encountered the same problem. It's because of memory limitation of iOS 8 keyboard extension.

As for now, the memory limitation for a keyboard extension is around 30MB. If your extension takes 40M memory as you said, it will be immidiately killed by the OS on a real iOS device.

However, when debuging it, iOS seems to no longer limit the memory usage of it.

Upvotes: 3

Related Questions