Skip to content

Commit 38445bc

Browse files
authored
Workaround for Javascript heap out of memory errors
Added workaround to deal with heap out of memory issues, which will happen for a reasonable sized app built on {N}. Please see NativeScript/nativescript-dev-webpack#458 **NOTE** Windows environment variable setting has not been tested by me - please confirm / verify it for Windows. macOS / Linux has been verified to work.
1 parent 65075ad commit 38445bc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/best-practices/bundling-with-webpack.md

+13
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,19 @@ const myPlugin = "my-plugin";
417417
global.loadModule(myPlugin);
418418
```
419419
420+
### Debugging Bundling Errors
421+
422+
#### Javascript heap out of memory
423+
424+
Bundle processing can consume a significant amount of memory, specically when using uglify `--env.uglify`. The default node process allocates 1.5GB memory. If you encounter issues similar to:
425+
`FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory`
426+
427+
Please set the following environment variable to allocate a larger heap size before running `tns build --bundle`, e.g. to allocate 4GB memory:
428+
For macOS / Linux:
429+
`export NODE_OPTIONS=--max-old-space-size=4096`
430+
For Windows:
431+
`set NODE_OPTIONS=--max-old-space-size=4096`
432+
420433
### Inspecting Bundles
421434
422435
Bundles are generated in the platform output folders. Look for the `bundle.js` and `tns-bundle.js` files in your `platforms/android/...` and `platforms/ios/...` "app" folders. You could change the destination directory by editing your configuration.

0 commit comments

Comments
 (0)