When I use eslint plugin in VSCode to lint a large bunch of files, the eslint server crashes. I try to find some way to add node options like "--max-old-space-size=4096", "--stack_size=10000" to start eslint server but failed.
crash message
[Info - 5:28:05 PM] ESLint server stopped.
[Info - 5:28:06 PM] ESLint server running in node v10.11.0
[Info - 5:28:06 PM] ESLint server is running.
[Info - 5:28:07 PM] ESLint library loaded from: /Users/dddong/workspace/JS2FuzzIL/node_modules/eslint/lib/api.js
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x10ae379d5 node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
2: 0x10ae37b4a node::get_builtin_module(char const*) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
3: 0x1077e2c6e v8::internal::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
4: 0x1078a3fc2 v8::internal::Heap::CreateFillerObjectAt(unsigned long, int, v8::internal::ClearRecordedSlots, v8::internal::ClearFreedMemoryMode) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
5: 0x1078a6703 v8::internal::Heap::CreateFillerObjectAt(unsigned long, int, v8::internal::ClearRecordedSlots, v8::internal::ClearFreedMemoryMode) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
6: 0x1078a272c v8::internal::Heap::CreateFillerObjectAt(unsigned long, int, v8::internal::ClearRecordedSlots, v8::internal::ClearFreedMemoryMode) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
7: 0x1078a0561 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
8: 0x1078acc75 v8::internal::Heap::RootIsImmortalImmovable(int) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
9: 0x1078accdf v8::internal::Heap::RootIsImmortalImmovable(int) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
10: 0x107449a73 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
11: 0x107625f8c v8::internal::RegisterConfiguration::AreAliases(v8::internal::MachineRepresentation, int, v8::internal::MachineRepresentation, int) const [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
12: 0x107a81d8e v8::internal::Parser::BuildIteratorCloseForCompletion(v8::internal::ZoneList<v8::internal::Statement*>*, v8::internal::Variable*, v8::internal::Expression*, v8::internal::IteratorType) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
<--- Last few GCs --->
[51895:0x10c8a7000] 785803 ms: Mark-sweep 2049.1 (2086.5) -> 2048.4 (2087.5) MB, 2049.2 / 0.0 ms (average mu = 0.073, current mu = 0.007) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x107a81d8e]
Security context: 0x039f533676d9 <JSObject>
1: /* anonymous */ [0x39f4467e3e1] [/Users/dddong/workspace/JS2FuzzIL/node_modules/acorn/dist/acorn.js:~4254] [pc=0x25db0d97b8c0](this=0x039f90bd4d69 <Parser map = 0x39fd3860a81>)
2: /* anonymous */ [0x39f4467c2e1] [/Users/dddong/workspace/JS2FuzzIL/node_modules/acorn/dist/acorn.js:~2728] [pc=0x25db0d875615](this=0x039f90bd4d69 <Parser map = 0x39fd3860a...
Eslint version: 1.9.0
Vscode version: 1.37.0-insider
@singleghost this can currently not be controlled.
What are you linting that 1 GB of memory is not enough. The server only validates the open files so that should be usually not be more than a handful?
Actually I open hundreds of file in vscode at same time. Just because using eslint in the vscode is convenient than using it in the command line 😄 . It would be helpful If can specify the argument for starting server.
There is also a lint task in VS Code that you can use to lint all the files without the need to open them. To enable the task use eslint.lintTask.enable using 1.9.1 of ESLint. You can also control the command line using eslint.lintTask.options
I have tried that task but it dumps it output to the integrated terminal not the problem panel. In the problem panel, I can easily jump to the desired position in the file but I can't do this in the integrated terminal.
It does both. It dumps the output to the terminal and captures problems from it that appear in the problems view. Doesn't that work for you?
Oh! It does dumps the output to the problems panel. However, I still cannot pass --max-old-space-size to it because it is a node argument.
How to you pass --max-old-space-size when running eslint in the terminal ?
like node --max-old-space-size=8192 eslint.js
OK. Makes sense
I get this sometimes as well if eslint is enabled and I open a directory without an eslintrc file, but am using the working directories option. I setup an ignore at the root and it seems to have helped.
I get this sometimes as well if eslint is enabled and I open a directory without an eslintrc file, but am using the working directories option. I setup an ignore at the root and it seems to have helped.
Yes, set a ignore would help. But I need eslint to lint large numbers of files at a time in vscode.
Completely agree.
Facing a similar issue with a similar error log as given in the issue description:

Normally, I run eslint from the command line like this: export NODE_OPTIONS=--max_old_space_size=4096 && eslint '**/*.*' --ignore-path ../../.eslintignore. Without increasing the memory usage, I get out-of-memory errors in command line also. If the server itself starts with higher allocated memory, it could solve it.
@maneetgoyal Totally agree!
I hit this problem constantly, and I believe it's because I use typescript-eslint which uses quite a lot of memory to gather type information for the project (as it needs to compile the whole project). Is microsoft/vscode-languageserver-node#467 something you'd like to fix and rely on for this issue? What approach would you recommend for implementing this?
I've ended up using the eslint.runtime option for this, with the script:
#!/bin/bash
echo "ESLint server using Node.js from: $0"
export NODE_OPTIONS=--max_old_space_size=4096
echo "ESLint server using NODE_OPTIONS: $NODE_OPTIONS"
node $@
I've ended up using the
eslint.runtimeoption for this, with the script:#!/bin/bash echo "ESLint server using Node.js from: $0" export NODE_OPTIONS=--max_old_space_size=4096 echo "ESLint server using NODE_OPTIONS: $NODE_OPTIONS" node $@
It is a nice approach to work around this.
I've ended up using the
eslint.runtimeoption for this, with the script:#!/bin/bash echo "ESLint server using Node.js from: $0" export NODE_OPTIONS=--max_old_space_size=4096 echo "ESLint server using NODE_OPTIONS: $NODE_OPTIONS" node $@
@bradleyayers @singleghost Can you please add some more details? I think I'm doing something wrong. Currently, I have this in my settings.json: "eslint.runtime": "./vscode-eslint.sh", and vscode-eslint.sh contains the code you suggested. Getting the following error:

Using absolute path for the bash script seemed to work, after chmod.
with this approach, I can't seem to get it to use the node version that the project is using. I tried setting vscode eslint runtime, setting default node version for nvm, opening code through command line. anyone able to get this to use the node version you want?
ok, update, if I nvm alias default 13.13.0, then open code from command line, this seems to be working to use the node I want.
Most helpful comment
I've ended up using the
eslint.runtimeoption for this, with the script: