“由于内存问题而终止" [英] "Terminated due to memory issue"

查看:52
本文介绍了“由于内存问题而终止"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 NotificationService 应用程序扩展中不断出现看似随机的崩溃.这是我的第一个应用程序扩展,所以我不确定调试通常如何工作,但我的异常断点没有被触发.扩展程序刚刚退出,默认通知通过.我已经能够使用行断点来追踪扩展崩溃的特定位置,并简单地单步执行直到它崩溃.奇怪的是,它每次都会始终在同一条线上崩溃(因此它似乎不是内存压力问题).我找不到任何这背后的任何韵律或原因.以下是一些崩溃示例:

I am getting constant and seemingly random crashes in my NotificationService app extension. This is my first app extension so I'm not sure how debugging normally works, but my exceptions breakpoint is not getting triggered. The extension just exits and the default notification goes through. I've been able to track down specific spots where the extension crashes using line breakpoints and simply stepping through until it crashes. The odd thing is that it will consistently crash on the same exact line every time (so it doesn't seem to be a memory pressure issue). I can't find any ryhm or reason behind any of this. Here are a few examples of crashes:

  • for key in dict.keys {} 但不是 for (key, _) in dict {}.
  • dateFormatter.date(from:) 但不仅仅是 dateFormatter.
  • attributes.count 其中,attributes 是自定义结构.
  • existingObjects.insert(newObject, at: 0) 但不是 existingObjects.append(newObject)
  • for key in dict.keys {} but not for (key, _) in dict {}.
  • dateFormatter.date(from:) but not just dateFormatter.
  • attributes.count where attributes is a custom struct.
  • existingObjects.insert(newObject, at: 0) but not existingObjects.append(newObject)

我没有在 iPhone 6 上看到崩溃,但我的 iPad Air 2、iPhone 6s Plus 和 iPhone 7 一直在同一条线上崩溃,直到我做出改变,这将崩溃移到了新的点代码.

I haven't seen the crash on my iPhone 6, but my iPad Air 2, iPhone 6s Plus and iPhone 7 all consistently crash on the same line until I make a change, which moves the crash to a new point in the code.

推荐答案

在停止了一些研究后,我终于偶然发现了答案:https://forums.developer.apple.com/thread/60632.

After quit a bit of research I finally stumbled onto the answer: https://forums.developer.apple.com/thread/60632.

确实是内存不足错误.我在 Xcode 工具中只看到 5mb,并认为它不可能以如此少的内存杀死进程,但 NotificationService 扩展的内存限制非常低,而且我链接的框架在大约 4mb 时启动了进程.事情发生在天平上只是时间问题.

It is indeed an out of memory error. I was seeing only 5mb in Xcode instruments and thought it couldn't possibly killing the process for so little memory, but NotificationService extensions have a very low memory limit and the frameworks I was linking against started the process out at around 4mb. It was just a matter of time before something tipped the scales.

这篇关于“由于内存问题而终止"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆