简体   繁体   中英

when i run the commande ng serve i get Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory error

I m using angular 9 and nodejs 12 When I enter ng serve , I'm facing the following issue:

 C:\Users\homz\my-app>ng serve 93% after chunk asset optimization SourceMapDevToolPlugin vendor.js generate SourceMap <--- Last few GCs ---> [3568:01DA56B8] 252182 ms: Mark-sweep 190.4 (193.9) -> 190.3 (194.4) MB, 756.7 / 0.1 ms (+ 180.7 ms in 13 steps since start of marking, biggest step 177.8 ms, walltime since start of marking 945 ms) (average mu = 0.106, current mu = 0.008) allocation f[3568:01DA56B8] 253111 ms: Mark-sweep 190.6 (194.4) -> 190.6 (194.9) MB, 741.2 / 0.1 ms (+ 185.4 ms in 5 steps since start of marking, biggest step 184.4 ms, walltime since start of marking 929 ms) (average mu = 0.059, current mu = 0.003) allocation fa <--- JS stacktrace ---> ==== JS stack trace ========================================= 0: ExitFrame [pc: 00D59EF7] Security context: 0x03bc0469 <JSObject> 1: substr [03BC9C49](this=0x137835b5 <Very long string[12707]>,8) 2: getOriginalSource(aka getOriginalSource) [1372D9FD] [C:\Users\homz\my-app\node_modules\webpack-sources\lib\ReplaceSource.js:119] [bytecode=11CB9EFD offset=129](this=0x01f00279 <undefined>,0x0dcc4fd9 <Object map = 0AC1BF95>) 3: _replaceInStringNode [0514A3CD] [C:\Users\homz\my-app\node_mod... FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 008BBD7A v8::internal::Heap::PageFlagsAreConsistent+3050 C:\Users\homz\my-app>ng serve 93% after chunk asset optimization SourceMapDevToolPlugin vendor.js generate SourceMap <--- Last few GCs ---> [2608:01DC5228] 202474 ms: Mark-sweep 189.7 (193.2) -> 189.5 (193.9) MB, 892.7 / 0.1 ms (average mu = 0.081, current mu = 0.006) allocation failure scavenge might not succeed [2608:01DC5228] 203373 ms: Mark-sweep 190.4 (193.9) -> 190.3 (194.4) MB, 699.2 / 0.1 ms (+ 192.1 ms in 13 steps since start of marking, biggest step 186.9 ms, walltime since start of marking 899 ms) (average mu = 0.046, current mu = 0.009) allocation f <--- JS stacktrace ---> ==== JS stack trace ========================================= 0: ExitFrame [pc: 00DA9EF7] Security context: 0x03740469 <JSObject> 1: substr [03749C49](this=0x12f4c8e1 <Very long string[12707]>,8) 2: getOriginalSource(aka getOriginalSource) [12DF6839] [C:\Users\homz\my-app\node_modules\webpack-sources\lib\ReplaceSource.js:119] [bytecode=1169D81D offset=129](this=0x01d00279 <undefined>,0x04188745 <Object map = 0ADC3A5D>) 3: _replaceInStringNode [0441AAA5] [C:\Users\homz\my-app\node_mod... FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0090BD7A v8::internal::Heap::PageFlagsAreConsistent+3050 C:\Users\homz\my-app>ng serve 93% after chunk asset optimization SourceMapDevToolPlugin vendor.js generate SourceMap <--- Last few GCs ---> on[3480:01D856B8] 285281 ms: Mark-sweep 190.6 (193.9) -> 190.4 (194.7) MB, 1331.4 / 0.1 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1331 ms) (average mu = 0.050, current mu = 0.003) allocation fail[3480:01D856B8] 286329 ms: Mark-sweep 190.4 (194.7) -> 190.4 (194.7) MB, 1047.5 / 0.1 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1048 ms) (average mu = 0.033, current mu = 0.011) allocation fail <--- JS stacktrace ---> ==== JS stack trace ========================================= 0: ExitFrame [pc: 00C49EF7] Security context: 0x03580469 <JSObject> 1: _replaceInStringNode [04B70FB5] [C:\Users\homz\my-app\node_modules\webpack-sources\lib\ReplaceSource.js:~194] [pc=139AB658](this=0x116d6429 <Source map = 0B0003FD>,0x1313d791 <JSArray[63403]>,0x1313d769 <ReplacementEnumerator map = 0343FF85>,0x1313d851 <JSFunction getOriginalSource (sfi = 0F15DFED)>,0x13081c21 <String[13]\: if (false) {\n>,1663649,0x119b72e1 <O... FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 007ABD7A v8::internal::Heap::PageFlagsAreConsistent+3050

You can try increasing the memory node can use

export NODE_OPTIONS="--max-old-space-size=4096"

You can also do that for a specific file instead. You might want to check at source-map alternatives like the webpack devtool: eval option

I had a similar problem on a different webpack based project:

You can also try:

optimization: {
    minimize: false,
},

in your webpack.config.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM