feat(ios): add getExtendedMemoryUsage() exposing resident size and region count#44
Open
maxim-smotrov wants to merge 2 commits into
Open
feat(ios): add getExtendedMemoryUsage() exposing resident size and region count#44maxim-smotrov wants to merge 2 commits into
maxim-smotrov wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
getMemoryUsage()only exposes iOSphys_footprint(the jetsam-accounted number that matches Xcode's memory gauge). That's the right primary signal, but it's not enough to actually diagnose memory problems in the field:phys_footprinthides fragmentation and leaks until it's too late. A steadily climbingregion_count(number of VM regions) is an early, reliable indicator of address-space fragmentation or leaked mappings - often visible well beforephys_footprintspikes.resident_sizegives the real physical-RAM picture. It complementsphys_footprint(which excludes shared/reclaimable memory) so consumers can tell why footprint is what it is.task_info(TASK_VM_INFO)call. These fields come back in the same struct, so reading them adds zero extra native calls or measurable overhead - which matters for a performance toolkit that must stay cheap.In short: for the cost of reading two extra fields that are already available, this gives advanced consumers the data they need to catch memory regressions early, without changing or slowing down the existing API.
Summary
Adds
getExtendedMemoryUsage()to read extra iOS memory stats (resident_sizeandregion_count) along with the usualphys_footprint- all from one native call.On iOS, the memory buffer grows from 4 to 24 bytes. Offset 0 is still the
phys_footprintvalue, sogetMemoryUsage()and everything else keeps working. Android is unchanged; the extra fields just return0there.Buffer layout (iOS)
Test plan
getExtendedMemoryUsage()returns non-zero resident size and regioncount, and
memoryUsageMbmatchesgetMemoryUsage().memoryUsageMbworks, extra fields are0.Important
Changes made with the help of AI, reviewed by a human