Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLAT-8000] Use DISPATCH_SOURCE_TYPE_MEMORYPRESSURE #1296

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Feb 16, 2022

Goal

Improve the accuracy of metaData.device.lowMemoryWarning to make it more likely that OOMs will contain this metadata.

Changeset

Creates a DISPATCH_SOURCE_TYPE_MEMORYPRESSURE source to receive memory pressure notifications.

This allows Bugsnag to be informed of memory pressure before UIApplication is able to send its UIApplicationDidReceiveMemoryWarningNotification.

lowMemoryWarning is now removed if memory pressure recovers.

Testing

Tested locally using example app, adding some log statements to show that DISPATCH_MEMORYPRESSURE notifictions arrive before the UIKit equivalents:

2022-02-16 14:50:25.192359+0000 objective-c-ios[841:80634] 1991 / 2958 MB (67%)
2022-02-16 14:50:25.195755+0000 objective-c-ios[841:80634] 1992 / 2958 MB (67%)
2022-02-16 14:50:25.199362+0000 objective-c-ios[841:80690] DISPATCH_MEMORYPRESSURE_CRITICAL
2022-02-16 14:50:25.199363+0000 objective-c-ios[841:80634] 1993 / 2958 MB (67%)
2022-02-16 14:50:25.200735+0000 objective-c-ios[841:80634] -[ViewController didReceiveMemoryWarning]

Presence of the metadata is verified in E2E tests here.

@github-actions
Copy link

Bugsnag.framework binary size increased by 992 bytes from 912,288 to 913,280

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.2%    +428  +0.2%    +428    __TEXT,__text
  +0.2%    +416  +0.2%    +416    String Table
  +0.2%    +336  +0.2%    +336    Symbol Table
  +8.4%    +288  +8.4%    +288    __TEXT,__gcc_except_tab
  +3.1%    +128  +3.1%    +128    Lazy Binding Info
  +1.2%     +56  +1.2%     +56    __DATA,__const
  +2.3%     +48  +2.3%     +48    __TEXT,__stub_helper
  +2.3%     +48  +2.3%     +48    __TEXT,__stubs
  +1.5%     +40  +1.5%     +40    Binding Info
  +2.3%     +36  +2.3%     +36    Indirect Symbol Table
  +0.3%     +32  +0.3%     +32    Export Info
  +2.3%     +32  +2.3%     +32    __DATA,__la_symbol_ptr
  +0.3%     +12  +0.3%     +12    __TEXT,__unwind_info
  +2.5%      +8  +2.5%      +8    __DATA,__got
  -0.1%      -8  -0.1%      -8    __DATA,__objc_selrefs
  -0.0%     -24  -0.0%     -24    __DATA,__objc_const
  -0.1%     -36  -0.1%     -36    __TEXT,__objc_methname
  -0.4%     -64  -1.6%     -64    [__DATA]
  -3.1%    -788  -3.1%    -788    [__TEXT]
  [NEW]      +4 -18.9%    -988    [__LINKEDIT]
  +0.1%    +992  [ = ]       0    TOTAL

Generated by 🚫 Danger

@nickdowell nickdowell merged commit 915dff2 into next Feb 17, 2022
@nickdowell nickdowell deleted the nickdowell/low-memory-warning branch February 17, 2022 10:44
@nickdowell nickdowell mentioned this pull request Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants