Closed michalchudziak closed 9 months ago
As delineated in the issue https://github.com/facebook/hermes/issues/878
Moving back to RN as per last comment on the linked issue
Is it possible that on iOS the bytecode bundle isn't being memory mapped and is instead read into a memory allocation?
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Is there any update or comparison in the latest version of react-native? We care about performance and memory consumption for TrustKeys Web3 SocialFi.
Description
As delineated in the issue https://github.com/facebook/hermes/issues/878, there appears to be an elevated memory usage on iOS when utilizing the Hermes JavaScript engine compared to the JavaScriptCore (JSC) engine.
This trend is noticeable even with a newly created application, where Hermes exhibits a substantial difference compared to JSC. The discrepancy seems to be increased by the complexity of an application, with larger applications demonstrating a ~20-30 MB higher memory consumption with Hermes.
While the overall elevated memory usage might be inherent to the Hermes engine itself, there is a particular allocation, significantly tied to the React Native core, which correlates with the size of the JavaScript bundle. This allocation is approximately
~1.17 MiB
for a sample application, but increases to more than20 MiB
for larger applications. Specifically, it is anNSData
object that is allocated when theexecuteApplicationScript
function is invoked.Here's a stack trace of the allocation in question:
React Native Version
0.71.8
Output of
npx react-native info
System: OS: macOS 13.0.1 CPU: (10) arm64 Apple M1 Max Memory: 224.94 MB / 64.00 GB Shell: 5.9 - /opt/homebrew/bin/zsh Binaries: Node: 16.19.0 - /usr/local/bin/node Yarn: 1.22.18 - /opt/homebrew/bin/yarn npm: 8.19.2 - /opt/homebrew/bin/npm Watchman: 2023.01.23.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.12.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: API Levels: 23, 25, 26, 28, 29, 30, 31, 32, 33 Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0, 33.0.0 System Images: android-29 | Google Play ARM 64 v8a, android-30 | Intel x86 Atom_64, android-30 | Google Play ARM 64 v8a, android-31 | Intel x86 Atom_64, android-31 | Google APIs ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-33 | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9014738 Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild Languages: Java: 11.0.17 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.8 => 0.71.8 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
npx react-native init TestHermes
Release
version on the device (in my case it's iPhone 7 14.4, but it's visible also on other iOS devices eg. iPhone 12 Pro 16.X):hermes_enabled => false
flag.Release
version on the deviceSnack, code example, screenshot, or link to a repository
With hermes:
Without hermes: