-
Notifications
You must be signed in to change notification settings - Fork 661
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
OOM crash on iOS #511
Comments
Looks like the maximum heap size has been exceeded. It is a configuration value, set to 512MB by default: hermes/public/hermes/Public/GCConfig.h Line 154 in f3b1f0c
I am not sure whether ReactNative overrides it on initialization or whether it provides a mechanism to change it. |
One curious bit is that at least for one user, this crash happens very shortly after launch, and I'd be amazed if the app was able to use that much memory so quickly. I can't find it now, but I thought I saw some reference around Hermes having another limit around number of properties on an object or something like that that (limiting them to a single page of memory?) but I might be misremembering. |
Hermes does have a restriction in number of properties in an object (around 200,000), but in this case the stack strongly suggests that the garbage collector thinks this is a real OOM (the null pointer dereference is deliberate, in order to cause a crash):
|
On iOS the limit appears to be 512 MiIB, as If you're directly constructing your It's also not super clear to me why a I've been able to directly copy the |
…Android Summary: I was noticing OOM crashes because the app uses just about 500 MiB. I investigated some more and realized that the Hermes default is 512 MiB, which Android overrides to 1024 MiB, and iOS does not override. I further investigated the Android Hermes config and figured it wouldn't hurt to copy it over to iOS. More context in [this GitHub comment](facebook/hermes#511 (comment)). Test Plan: Make sure iOS stops crashing when logged in with my user Reviewers: karol-bisztyga, palys-swm Reviewed By: palys-swm Subscribers: KatPo, Adrian, atul Differential Revision: https://phabricator.ashoat.com/D1764
@Ashoat yup I agreed that we should increase the MaxHeapSize to at least 1GiB for whom using the default set up. Maybe even 3GiB which is "unlimited" in practice.
We only support Android back to that time. It was increased to mediate a similar issue #295. |
|
@Ashoat Thanks for pulling off this. I'm wondering would it make more sense to just increase the default number within Hermes and remove the |
For context, are there any additional changes needed to this PR for heap size increase to be actually applied on IOS? |
The goal of my work here is to eventually update the default heap size on iOS, but the above PR is only the first part. If you want to customize the heap size of a Hermes iOS app you should implement a custom |
After implementing a custom jsExecutorFactoryForBridge, do you know of a way to verify or log that the max heap size has been set as expected for the runtime in use? |
I'll update the default heap size but that will only be available until the next Hermes (and React Native) release (presumably 0.9 unless people felt like they really need a patch release). In the meantime, feel free to override the
Unfortunately there isn't an easy way that I'm aware of. The closest one that we exposed to JavaScript is |
Closing since this iOS OOM issue should be solved by upgrading to Hermes 0.9 (shipped with the upcoming RN 0.66) which includes the fix 5f2b47d that increase the default max heap size from 512MiB to 3GiB (which is "unlimited" in practice and make us more or less on par with the JSC unlimited behavior). (I made a typo in the commit summary so it's not linked to this issue 😅 ) Big shout out to @Ashoat to all the investigation and effort he made that helped us resolving this and similar memory issue going forward! |
Bug Description
This started showing up on BugSnag after release, no obvious correlation with particular device/OS version. Looks like an out-of-memory issue, but free memory shows as considerable in all the reports and didn't have any issues with JSC.
gradle clean
and confirmed this bug does not occur with JSCHermes version: 0.7.2
React Native version (if any): 0.64.1
OS version (if any): iOS (various)
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): arm64-v8a
Steps To Reproduce
Unfortunately don't have any yet.
The Expected Behavior
The text was updated successfully, but these errors were encountered: