App Extension “Terminated due to memory issue”

試著忘記壹切 提交于 2019-12-23 19:15:28

问题


In my app Notification Service Extension I do the following things: - get data (in background) from Parse, - write data to file - save data in NSUserDefaults (in a shared container).

Sometimes I get the message: "Terminated due to memory issue". No other information about what causes this.

Anybody experience with this? This strange thing is that it only happens now and then.


回答1:


There is a memory limit in notification service extension. You are supposed to use memory less than about 4.5M. So avoid using NSUserDefaults. And Try to save memory you use.

Just learned this today. NSUserDefaults is stored as property list files. And when you read single value from a property list, the whole property list is deserialized at once, causing rapid increasing in memory using. I think that's why reading values from NSUserDefaults in notification service extension causes memory problem.



来源:https://stackoverflow.com/questions/41190398/app-extension-terminated-due-to-memory-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!