Nativescript-cli: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Created on 27 Oct 2016  路  7Comments  路  Source: NativeScript/nativescript-cli

Tell us about the problem

The tns livesync android --watch command throws a fatal error while syncing an application:
https://gist.github.com/vchimev/ff09a52344deeda9ab8726b393856145
https://gist.github.com/vchimev/a6432699227d7faa99e2a1b00e2bc396
https://gist.github.com/vchimev/ebb14fa5f8bec922ea8b8c3008f0977a
https://gist.github.com/vchimev/62e757711b27d9a82605f781fea265ad

Please provide the following version numbers that your issue occurs with:

  • CLI: 2.5.0-2016-10-27-6956
  • Cross-platform modules: 2.5.0-2016-10-26-4569
  • Android runtime: 2.5.0-next-2016-10-26-1317

    Please tell us how to recreate the issue in as much detail as possible.

App: https://github.com/NativeScript/NativeScript/tree/master/apps
Emulator: Api 24 - Intel x86 Atom System Image

Change the _apps/app/ui-tests-app/flexbox/flexbox.ts_ file.
It seems that something during

Hook completed
7:10:13 PM - File change detected. Starting incremental compilation...

causes the error.

bug

Most helpful comment

I saw that my problem was, of course, my 32bits environment, so I change 'native-dev-typescript\lib\compiler.js' to set '--max_old_space_size=4096' to '--max_old_space_size=2048'
and set JAVA_OPTS = -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m.

It works to me!

All 7 comments

According this stackoverflow thread the problem may be allocating too much memory. Here is the suggested sollution

node --max_old_space_size=4096 yourFile.js

I am not sure how we can test it in the context of tns without manual editing the file.

The fix will be included in [email protected].

I'm using [email protected], and all libs up to date, and it isn't working, I'm getting the same error.
And I have only 4gb of RAM

I saw that my problem was, of course, my 32bits environment, so I change 'native-dev-typescript\lib\compiler.js' to set '--max_old_space_size=4096' to '--max_old_space_size=2048'
and set JAVA_OPTS = -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m.

It works to me!

alansousa hi bro can you plz tell where you have set JAVA_OPTS = -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m
I am still getting error althogh i have set 'native-dev-typescript\lib\compiler.js' to set '--max_old_space_size=4096' to '--max_old_space_size=2048'

Solution that worked for me :

_webpack.config.js_

if (uglify) {
        config.plugins.push(new webpack.LoaderOptionsPlugin({ minimize: true }));

        // Work around an Android issue by setting compress = false
        const compress = platform !== "android";

        config.plugins.push(new UglifyJsPlugin({
            parallel: true,
            uglifyOptions: {
                mangle: { reserved: nsWebpack.uglifyMangleExcludes },
                compress,
            },
            cache: join(__dirname, 'webpack-cache/uglify-cache')
        }));
    }

The build time is even faster !

Hi all i also got same error but not solved by all above then
I updated the NS-Webpack plugin version to latest i solved my problem

Was this page helpful?
0 / 5 - 0 ratings