How to increase memory use on run nativescript - node.js

I running code nativescript code with command tns run android --bundle and its also run with memory 4096MB. My RAM is 16. Why can it run on 4 not over more?
"Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Searching for devices...
Running webpack for Android...
clean-webpack-plugin: P:...\platforms\android\app\src\main\assets\app*** has been removed.
File change detected. Starting incremental webpack compilation...
Starting type checking service...
Using 1 worker with 4096MB memory limit"

This log is produced by the ForkTsCheckerWebpackPlugin.
Just open your <projectRoot>/webpack.config.js file and increase the memoryLimit property in the ForkTsCheckerWebpackPlugin initialization.

Related

How can I prevent React and Plotly crashing the development server due to JavaScript heap out of memory?

I am trying to build a create-react-app with react-plotly.js but when the plot components are included the compiler hangs and eventually fails displaying the error:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I checked the node heap limit using this command:
node -e 'console.log(`node heap limit = ${require("v8").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'
which returned:
node heap limit = 1456.1747760772705 Mb
I am using the WSL 2 Linux subsystem for Windows.
I have tried editing the package.json and replacing react-scripts start
with node --max_old_space_size=4096 node_modules/.bin/react-scripts start as suggested in this answer but the error was the same. I have also tried reducing it and using 512 as I have read that is sometimes advised if there is not enough space on the machine.
Any ideas how I can get this to work?
I had success resolving this issue by disabling the GENERATE_SOURCEMAP flag in my .env file, ie
GENERATE_SOURCEMAP=false
as suggested by the (slightly unrelated) answer here.

Webpack runs out of memory

Scenario
I have a 500MB RAM build machine and I want to use it to build a JavaScript bundle using webpack.
NODE_ENV=production webpack --config webpack.prod.js
This worked fine before, but as the project grew bigger, I started running out of memory. I tried setting an upper limit for node, hoping that webpack will do something smart but nope.
NODE_OPTIONS="--max-old-space-size=2048" NODE_ENV=production webpack --config webpack.prod.js
Constraints
Time it takes to build is not important to me. If we have to use the SSD for the build, that is fine.
This is a Linux box, but I have no swap.
I am happy for alternative solutions in my architecture, currently I output one single 1.6MB JS blob for my SPA.
Errors
Errors when running out of memory
FATAL ERROR: NewSpace::Rebalance Allocation failed - process out of memory
Error when I add restriction for node
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Any help or recommendations are greatly appreciated. Thanks!
Edit: additional info
"webpack": "4.6.0",
"webpack-cli": "2.0.15",

Nodejs Appveyor build running out of memory

We're running builds on AppVeyor to build an AOT angular 2 application.
The build has started failing, giving the following:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
From what I can tell, you can use --max_old_space_size=xxxx where xxxx is the size you want to increase memory to. The default is 512.
The problem is, I'm not sure where to add this flag. I've tried both dashes (what I found originall) and underscores. I've placed the flag as part of the ps build command definition, in the build scripts build configuration, and in the package.json scripts definitions to no avail.
I'm sure this just has to be put in the right spot, but I'm unclear as to where to add it. Any help would be appreciated.
Thanks
In appveyor.yml:
init:
- ps: Install-Product node 8
- cmd: set NODE_OPTIONS=--max-old-space-size=1028
This sets a node env var during init. Set it as high as you like.
This reduced build times for us by about 80% as well. Incredible.

npm publish - out of memory

I'm on Windows (and using nvm). I want to publish a ~200mb module to our private npm repo but I get
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I found out, that I should try to increase my memory usage. I'm not sure if I did it correctly because I'm on Windows and use nvm (currently using node v6.10.0), so my command looked like this:
node --max-old-space-size=4096 C:\\Users\\MyName\\AppData\\Roaming\\nvm\\v6.10.0\\node_modules\\npm\\bin\\npm-cli.js publish
but I ran into the same issue.
While doing so, I had a look into my task manager and the node process only allocated ~1.4GB memory - so how can I still have an out of memory error when my memory limit isn't reached? And, of course, how can I publish my module?

ubuntu 14.04 LTS webpack --watch not recompiling after a few times

I'm using Webpack along with Babel to compile my jsx into js. --watch will work a few times but then stop afterwards. I've had to resort to manually typing in webpack every time in order to make sure my scripts get compiled.
I had a similar problem to this where it turned out that webpack was silently failing to report that I had exceeded the max number of inotify watchers in Linux. Webpack watch uses inotify to observe file changes.
You can immediately try a fix to see if it works with:
sudo -i
echo 1048576 > /proc/sys/fs/inotify/max_user_watches
exit
The long term fix would be to increase your allowed watchers by editing your /etc/sysctl.conf to include this line: fs.inotify.max_user_watches=1048576.
The issue was reported here: https://github.com/webpack/webpack/issues/1281

Resources