angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

webpack ng serve runs out of memory

Open slubowsky opened this issue 10 years ago • 107 comments

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Windows 10
  2. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here: angular-cli: 1.0.0-beta.11-webpack.2 node: 6.3.1 os: win32 x64
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc. Keep ng serve running and serving a cli built app while coding for some time (a few hours?)
  4. The log given by the failure. Normally this include a stack trace and some more information.
...
 94% asset optimization
<--- Last few GCs --->

12936118 ms: Mark-sweep 1360.3 (1435.0) -> 1356.1 (1435.0) MB, 959.3 / 0 ms [all
ocation failure] [GC in old space requested].
12936973 ms: Mark-sweep 1356.1 (1435.0) -> 1356.0 (1435.0) MB, 854.9 / 0 ms [all
ocation failure] [GC in old space requested].
12938085 ms: Mark-sweep 1356.0 (1435.0) -> 1356.0 (1435.0) MB, 1112.2 / 0 ms [la
st resort gc].
12939012 ms: Mark-sweep 1356.0 (1435.0) -> 1355.8 (1435.0) MB, 926.7 / 0 ms [las
t resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 000001F1975C9E51 <JS Object>
    1: replace [native string.js:~129] [pc=0000018EE86B74E5] (this=000000EF14282
331 <String[61]: D:/it/node_modules/@angular/common/src/pipes/common_pipes.js>,
N=000000EF140824C9 <JS RegExp>,O=00000135F03D7F21 <String[10]: !(webpack)>)
    2: shorten [D:\it\node_modules\webpack\lib\RequestShortener.js:~41] [pc=000
0018EE4290DA2] (this=0000020E88D58019 <a RequestShortener with map 00000313C3C4.
..

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memo
ry
  1. Mention any other details that might be useful.

Only happened once so far but thought it worth mentioning


Thanks! We'll be in touch soon.

slubowsky avatar Aug 11 '16 20:08 slubowsky

@vitor-belim No, only on that function. I'm thinking it has something to do with differing return types in a function. In my case it was returning either an ErrorObservable or Observable<{success: boolean, errors: string[]}>.

thecheeto avatar Feb 23 '18 17:02 thecheeto

This has been changed in angular 7 now. I couldn't able to find the path of ng.. Please any help for finding its path in node modules..

`> node --max_old_space_size=5048 ng build --prod --aot --source-map=false

module.js:540 throw err; ^

Error: Error: Cannot find module '/Users/work/ui/node_modules/@angular/cli/bin/ng' at Function.Module._resolveFilename (module.js:538:15) at Function.Module._load (module.js:468:25) at Function.Module.runMain (module.js:684:10) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build-script-a7: node --max_old_space_size=5048 ng build --prod --aot --source-map=false npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build-script-a7 script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/.npm/_logs/2019-01-28T08_13_45_344Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: npm run config -- --environment=prod && npm run build-script-a7 && npm run prod-server npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/.npm/_logs/2019-01-28T08_13_45_364Z-debug.log`

prudhvichitturi avatar Jan 28 '19 08:01 prudhvichitturi

@prudhvichitturi node --max_old_space_size=5048 ./node_modules/.bin/<ng command>

strizich avatar Jan 31 '19 19:01 strizich

this worked for me:

"start": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng serve",

httpete avatar Feb 15 '19 19:02 httpete

"scripts": { "ng-custom-serve": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng serve" } as suggested by @RicTheThird this is what i have done to resolve,having ng serve as well,but will this hold good?,what if the application grows?Can we hope on this and go ahead?Any help would be great?

this is simple and fuction for me :3

uriel2095 avatar Apr 17 '19 22:04 uriel2095

It's weird that I have to tell Angular CLI/Node.js how much memory it can use.

Chrome/V8 seems happy to use all my memory.

pauldraper avatar Apr 18 '19 14:04 pauldraper

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.