“由于存储器问题而终止”; [英] "Terminated due to memory issue"

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

问题描述

我的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:


  • 键入dict.keys {} ,但不是dict {}中的(key,_)的

  • dateFormatter.date(from: ),而不仅仅是 dateFormatter

  • attributes.count 其中属性是自定义结构。

  • 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天全站免登陆