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-8411] Add device.freeMemory to OOM and Thermal Kill events #1357

Merged
merged 2 commits into from
May 10, 2022

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented May 9, 2022

Goal

Provide recent memory statistics to improve confidence in OOM errors.

Changeset

Adds an availableMemory field to BSGRunContext and updates this in the timer callback (twice per second) and in response to a memory pressure notification.

Only on iOS/tvOS 13 and later where os_proc_available_memory() is available.

ℹ️ Does not update BSGRUNCONTEXT_VERSION since no release yet contains BSGRunContext.

Performance

os_proc_available_memory() is much faster than calling host_statistics() or task_info()... ~150 vs ~700 nanoseconds on an iPhone SE (2020).

Testing

Amends E2E scenarios to verify presence of device.freeMemory

@nickdowell nickdowell force-pushed the nickdowell/oom-free-memory branch from 20e5ad6 to 486e472 Compare May 9, 2022 12:44
@github-actions
Copy link

github-actions bot commented May 9, 2022

1 Warning
⚠️ This PR modifies BSGRunContext.h but does not change BSGRUNCONTEXT_VERSION

Bugsnag.framework binary size increased by 120 bytes from 846,008 to 846,128

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +148  +0.1%    +148    __TEXT,__text
  +0.1%     +80  +0.1%     +80    Symbol Table
  +0.0%     +40  +0.0%     +40    String Table
  [ = ]       0  +0.2%     +16    __DATA,__bss
  +0.1%      +4  +0.1%      +4    __TEXT,__unwind_info
  [ = ]       0  -0.1%     -16    [__DATA]
  [ = ]       0  -2.0%    -120    [__LINKEDIT]
  -0.6%    -152  -0.6%    -152    [__TEXT]
  +0.0%    +120  [ = ]       0    TOTAL

Generated by 🚫 Danger

@nickdowell nickdowell requested review from kattrali and kstenerud May 9, 2022 13:05
@@ -278,7 +279,5 @@ Feature: Barebone tests
And the error payload field "events.0.app.duration" is null
And the error payload field "events.0.app.durationInForeground" is null
And the error payload field "events.0.device.freeDisk" is null
And the error payload field "events.0.device.freeMemory" is null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be checked for an integer as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

device.freeMemory is now checked as being an integer on line 239

@nickdowell nickdowell marked this pull request as ready for review May 10, 2022 13:57
@nickdowell nickdowell merged commit 2bfc542 into next May 10, 2022
@nickdowell nickdowell deleted the nickdowell/oom-free-memory branch May 10, 2022 15:14
@nickdowell nickdowell mentioned this pull request May 11, 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.

4 participants