EsLint
在一个
大型javascript文件,进程内存不足。让你知道我运行的文件有多大
Cloc
上面是输出:
$ cloc app.js
1 text file.
1 unique file.
0 files ignored.
github.com/AlDanial/cloc v 1.80 T=12.81 s (0.1 files/s, 42499.8 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
JavaScript 1 4255 23744 516524
-------------------------------------------------------------------------------
$ ls -lAh app.js
-rw-r--r-- 1 miguelangel staff 23M Jan 28 11:58 app.js
这就说明这很可能
不
EsLint内存泄漏。我在Github.com中看到了EsLint内存泄漏的一些问题。我想这里不是这样的。
文件这么大是因为它是连接许多其他Javascript模块的结果。我在这里的目的是试图找到任何未使用的代码。这个项目的代码库显然在没有控制的情况下增长了,我正在努力消除死角。所以我想逃跑
EsLint's
no-unused-vars
rule
.eslintrc.js公司
module.exports = {
"env": {
"browser": true,
"commonjs": false,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2015
},
"rules": {
"no-unused-vars": [
"warn"
]
}
};
这个项目既不是Node也不是AMD项目,所以我想我必须将整个代码库放在一个文件中,以避免误报。
问题是试图对此文件运行EsLint会导致
JavaScript heap out of memory
错误。
$ eslint app.js
<--- Last few GCs --->
[60451:0x104002200] 43814 ms: Mark-sweep 1395.7 (1424.1) -> 1395.2 (1423.6) MB, 5719.6 / 0.0 ms (+ 0.1 ms in 28 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 5755 ms) (average mu = 0.148, current mu = 0.037) alloca[60451:0x104002200] 49447 ms: Mark-sweep 1397.4 (1424.1) -> 1396.9 (1425.6) MB, 5569.8 / 0.0 ms (+ 0.1 ms in 11 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 5598 ms) (average mu = 0.081, current mu = 0.011) alloca
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x3275f3d4fb7d]
Security context: 0x14c691f9d969 <JSObject>
1: /* anonymous */ [0x14c6f1b7b981] [/usr/local/lib/node_modules/eslint/node_modules/acorn/dist/acorn.js:~2868] [pc=0x3275f40f5843](this=0x14c6b794c669 <Parser map = 0x14c603088f11>)
2: /* anonymous */ [0x14c6f1b7b111] [/usr/local/lib/node_modules/eslint/node_modules/acorn/dist/acorn.js:2190] [bytecode=0x14c691fecb01 offset=968](this=0x14c6b794c669 <...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x10003ace0 node::Abort() [/usr/local/bin/node]
2: 0x10003aeb1 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
3: 0x10018c8cf v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
4: 0x10018c870 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
5: 0x10047b188 v8::internal::Heap::UpdateSurvivalStatistics(int) [/usr/local/bin/node]
6: 0x10047cc01 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
7: 0x10047a4c4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
8: 0x100479236 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
9: 0x100481826 v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x100481b5c v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x100461562 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
12: 0x100653464 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
13: 0x3275f3d4fb7d
Abort trap: 6
如何增加EsLint对内存的访问?