5

I am developing a ios 8 custom keyboard Extension. It run like a charm start.

But I always get "Receive Memory Warning" in Xcode. So my custom keyboard extension will suddenly terminate sometimes.

But I run the custom keyboard in its host app. There don't have any problem. Don't get "Receive Memory Warning" in Xcode. Don't terminate.

Anybody can help me? If app have any limit size for a Extension use?

Terminated due to Memory Error

Community
  • 1
  • 1
Rick Wu
  • 61
  • 1
  • 4
  • 1
    I use https://github.com/Split82/iOSMemoryBudgetTest test my device (ipad 3 wifi). A app will crash when memory reach 600MB. But my custom keyboard Extension only need almost 30M. iOS still give Memory Warning. There have any document about this problem? – Rick Wu Aug 18 '14 at 06:01
  • 1
    I did more test. I add iOSMemoryBudgetTest into my custom keyboard. I got the custom keyboard extension will crush reach 40M! – Rick Wu Aug 18 '14 at 06:03
  • I really don't know if it is only this problem in iOS beta 5. Or official release version will fix this problem? – Rick Wu Aug 18 '14 at 07:38
  • possible duplicate of [Is it possible to debug "Terminated due to memory error"?](http://stackoverflow.com/questions/19203790/is-it-possible-to-debug-terminated-due-to-memory-error) – Andrew Aug 21 '14 at 20:01
  • 1
    @SantaClaus, no. That topic discuss app not Extension – Rick Wu Aug 23 '14 at 05:41
  • Try what it suggests. It should work the same way. – Andrew Aug 23 '14 at 13:12

2 Answers2

4

Apple mentions in their App Extension Programming Guide that memory limits for app extensions are significantly lower than limits imposed on foreground apps. Additionally some types of extensions may have lower limits than others.

Apple is not explicit about these memory limits as far as I can tell and it's unclear if they are dependent on the device and how much memory other apps are consuming. But as Ethan mentioned, for keyboard extensions you should aim for less than 30MB to avoid crashing.

It's also important to test the extension when not running in Xcode or using a debug build configuration. It seems that the memory limits for debug builds are much higher.

Jeff Ames
  • 1,555
  • 11
  • 27
  • Its annoying that Apple is being coy. Apple, Just tell us what the damn limit is! – Mark Johnson Mar 19 '15 at 00:54
  • what will you do if Apple give you the limite ? monitor your app memory usage and if it reach the X MB you will do something ? you already have the warning .. – Red Mak May 19 '16 at 00:34
  • You can see the actual limit in your Xcode. Attach debugger to your extension, run it, go to Debug Navigator > Memory and see the graf (plot). The limit appears there if you reach close to it. In my Call Directory extension, the limit is 12MB, which is great for my tens of thousands phone numbers. Thank you Apple very much. – Štěpán Feb 13 '20 at 13:04
  • Printscreen where you can see the memory limit: https://eway.cr/xcoderamlimit – Štěpán Feb 13 '20 at 13:14
3

iOS allocates less memory to extensions as they are supposed to be light and do one thing well. I suppose shall try limit memory use under 30mb...

Ethan Long
  • 745
  • 1
  • 6
  • 15