nativescript-dev-webpack icon indicating copy to clipboard operation
nativescript-dev-webpack copied to clipboard

Spawn webpack process with custom --max_old_space_size

Open jfturcot opened this issue 7 years ago • 7 comments

Would it be possible for you to add to following to compiler.js:

--max_old_space_size=4096

I am building a very large Nativescript app and AOT was just refusing to build, I was always throwing the javascript memory heap error. Adding that to the args in compiler.js fixed it for me.

nativescript-dev-typescript has already added that line to the node args in compiler.js, I guess that it shouldn't be a problem adding it here also if no one ever complained about memory issues with nativescript-dev-typescript.

Thanks! :)

jfturcot avatar Jan 31 '18 01:01 jfturcot

We'll consider adding this to the next release. It may be a good idea for the value to be customizable instead of locked down to 4096 as in the typescript plugin.

sis0k0 avatar Jan 31 '18 09:01 sis0k0

I fully agree that it should be a customizable value, I only proposed that fixed value because that's what the typescript package was using. It should both have a customizable value that could be set using an argument added to tns build

Thanks!

jfturcot avatar Jan 31 '18 16:01 jfturcot

Hi im having issues now with the value of 4096 the error is java heap memory i tried running the command generated with 8196 and it works but i dont know where to change it permanently plz help

cabaji9 avatar Dec 16 '19 17:12 cabaji9

@cabaji9 these days I use an environment variable to always have it set in my shell. I use ZSH, but should work with BASH too. Add this to your .bashrc (edit the space size for your needs): export NODE_OPTIONS=--max-old-space-size=4096

jfturcot avatar Dec 16 '19 17:12 jfturcot

thx i added that too yet the value its unchanged this keeps appearing on the log with --log trace ,, .nvm/versions/node/v12.10.0/bin/node "--max_old_space_size=4096"

This same project works fine on windows and mac os on arch linux not,

Somehow the value its burned somewhere,

cabaji9 avatar Dec 16 '19 18:12 cabaji9

@cabaji9 I am using Arch also, works fine for me, but let me try to help you, I spent a lot of time on this and I remember how frustrating it was. I assume you changed the value in my example to your value of 8196? What happens if instead of adding it to your bashrc, you add it before the tns build command? NODE_OPTIONS=--max-old-space-size=8196 tns build ... Are you sure you never added that environment variable to any of your dotfiles for your shell (bash)?

jfturcot avatar Dec 16 '19 18:12 jfturcot

i found the error i had another node_modules cause i was migration to nativescript 6 and angular 8, i was keeping the old node modules as a backup with the name node_modules_backup yet it was being added on the compilation and the memory was insufficient. Thx,

cabaji9 avatar Dec 16 '19 19:12 cabaji9