iphone - iOS 低内存崩溃,但内存使用率非常低

标签 iphone objective-c ios ipad memory-management

这个问题困扰了我很久。我的应用程序运行占用了大约 2.74MB 的内存。没关系。但是当它创建一个 UIWebView 时,它会上升到大约 5.87MB 并继续崩溃。这些是在我的第一代 iPad 上运行时在 Instruments 中的 Live Bytes 下给出的值。

我找不到崩溃日志。以下来自控制台:

MyApp[1205] <Warning>: Received memory warning. Level=1
MyApp[1205] <Warning>: applicationDidReceiveMemoryWarning
SpringBoard[30] <Warning>: Received memory warning. Level=1
MobileMail[1199] <Warning>: Received memory warning. Level=1
configd[26] <Notice>: jetsam: kernel memory event (95), free: 428, active: 1853, inactive: 1011, purgeable: 338, wired: 15122
configd[26] <Notice>: jetsam: kernel termination snapshot being created
com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.mobilemail[0x8966]) Exited: Killed: 9
com.apple.launchd[1] <Notice>: (UIKitApplication:com.MyApp.MyApp[0xdd4f]) Exited: Killed: 9
SpringBoard[30] <Warning>: Application 'Mail' exited abnormally with signal 9: Killed: 9
kernel[0] <Debug>: launchd[1207] Builtin profile: MobileMail (sandbox)
SpringBoard[30] <Warning>: Application 'MyApp' exited abnormally with signal 9: Killed: 9
configd[26] <Debug>: CaptiveNetworkSupport:UIAllowedNotifyCallback:70 uiallowed: false
ReportCrash[1206] <Error>: libMobileGestalt loadBasebandMobileEquipmentInfo: CommCenter error: 1:45
ReportCrash[1206] <Error>: libMobileGestalt copyInternationalMobileEquipmentIdentity: Could not get mobile equipment info dictionary
ReportCrash[1206] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2011-05-12-160645.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0

我已删除所有对 imageNamed 的调用,将自动释放的内容更改为分配/释放。但我无法弄清楚为什么会发生这种情况,这让我发疯。

感谢您的帮助!

最佳答案

几乎可以肯定,您使用的内存比您想象的要多。

你必须做什么才能看到你的应用真正使用了什么并不明显,但是一旦你做了几次,你就会记住。

  1. 使用分配性能工具运行。
  2. 点击“Allocations”下的 VM Tracker“行”(在屏幕截图中)
  3. 点击“自动快照”

然后你会看到你的脏内存(在我的截图中当前是 20.34MB)。

这应该让您更好地了解您的应用退出的原因。你可能发生了一些大的泄漏。

祝你好运!

This screenshot will help

关于iphone - iOS 低内存崩溃,但内存使用率非常低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5980636/

相关文章:

ios - 文件播放后我的应用程序崩溃 (Swift)

iphone - IOS:在父 View 上移动 subview

ios - cocoapods 重复符号 _OBJ_METACLASS_$PodsDummy_Pods_xxx

ios - 当 iOS 应用程序在前台时处理小部件单击操作

iphone - 我想在 iOS 中实现图像处理算法,你能推荐一些好的入门指南吗

iphone - 在 XCode 中本地化 HTML 文件

iphone - Objective-C中如何返回非对象类型的数组列表

ios - MKMapView 未在 mapType MKMapTypeStandard 和 MKMapTypeHybrid 上加载

ios - 从 UIWebView 中移除 div

ios - Swift:如果在 PFQuery 完成之前再次运行函数,如何取消 PFQuery?