[PLAT-8706] Capture app memory stats #1435
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
Capture richer information to help developers understand the app's memory usage at the time a crash or other error occurrs.
Design
Adds
freeMemory
,memoryLimit
andmemoryUsage
tometaData.app
for all kinds of errors.Makes
device.freeMemory
always report the number of free bytes available on the device, as it was prior to #851 (release v6.2.3), and includes it in OOM errors.Changeset
Polls
task_info
instead ofos_proc_available_memory
so that we have the footprint as well as available bytes, allowing the memory limit to be computed.Moves all "live" memory stats to
BSGRunContext
and updates crash report writing and error payload generation to read frombsg_runContext
.Polls
host_statistics
to have reasonably accuratedevice.freeMemory
values in OOM errors.Testing
Adds basic unit tests to verify memory stats are as expected.
Amends E2E scenarios to verify the presence of memory stats.
Performance
Since
task_info
andhost_statistics
are more expensive thanos_proc_available_memory
some benchmarking was performed with an iPhone SE (2020).The average measured execution times were:.
task_info
+host_statistics
.os_proc_available_memory
.With the default polling rate (2 Hz) CPU usage was not measurable by Xcode or Instruments, including on older hardware such as an iPad 3rd generation.
To understand the relative impact of this change, measurements were taken with an increased polling rate of 1000 Hz:
task_info
+host_statistics
.os_proc_available_memory
.