How to increase memory of Metro Bundler when loading large assets?

#1

Hi,

I am trying to bundle an expo app for development, using exp start.
The app contains a lot of static assets, primarily animations ~250 MB. When I am trying to bundle the app, I encounter the following error:

[18:13:23] FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
[18:13:23] 1: 00007FF662D79055
[18:13:23]  2: 00007FF662D52FE6
[18:13:23]  3: 00007FF662D538C0
[18:13:23]  4: 00007FF6631A71DE
[18:13:23]  5: 00007FF6631A7113
[18:13:23]  6: 00007FF66321C004
[18:13:23]  7: 00007FF663219DBA
[18:13:23]  8: 00007FF663055D0C
[18:13:23]  9: 00007FF663001599
[18:13:23] 10: 00007FF662FF28EB
[18:13:23] 11: 00007FF6631C1BA4
[18:13:23] 12: 00007FF662D3DBFA
[18:13:23] 13: 00000356A5084780
Building JavaScript bundle [====================================================================================================] 100%
Stopping packager...
Packager stopped.

I see that previous solutions for RN have involved increasing the heap memory using the command:

https://github.com /facebook/react-native/issues/12686 

node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --entry-file ./index.ios.js --platform ios --dev false --bundle-output "ios/main.jsbundle" --assets-dest "ios" --reset-cache

However, I have not found a working solution for expo.

Any ideas?

#2

Hey @modde,

Pinged internally about this. I’ll either circle back myself or another member of the Expo team may hop in here once we have an answer.

Cheers,

Adam

#3

Can you make sure all file extensions of those large files are added to app.json, under packagerOpts.assetExts? Not adding a file extension in this list causes Metro bundler to treat files with that extension as source files, which are loaded to memory, which would cause this problem.

If doing that and then clearing the cache with exp start --clear doesn’t fix the problem, please let us now which SDK version you’re using and share the app.json configuration you’re using, or even better, a GitHub repo with an example that reproduces the issue.

#4

Appreciate you looking into this.

@fson the file extension for the animation is GLTF and the file extension is in app.json. The GLTF animations are loaded using the GLTF Loader for Expo.

exp start --clear does not solve the issue. Using only half of the animations works without a hitch.
We are on SDK 28 and below you can find our app.json:

{
  "expo": {
    "name": " ",
    "description": " ",
    "slug": " ",
    "privacy": "unlisted",
    "sdkVersion": "28.0.0",
    "scheme": " ",
    "ios": {
      "bundleIdentifier": " ",
      "supportsTablet": true
    },
    "android": {
      "package": " "
    },
    "platforms": [
      "ios",
      "android"
    ],
    "version": "0.0.5",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/icon.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "packagerOpts": {
      "assetExts": [
        "ttf",
        "mp4",
        "dae",
        "obj",
        "amf",
        "3mf",
        "3ds",
        "jpg",
        "assimp",
        "fbx",
        "pmd",
        "vmd",
        "ply",
        "stl",
        "vtk",
        "vtp",
        "sea",
        "gltf",
        "bin"
      ]
    }
  }
}
closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.