visual-studio-codepylance

Visual Studio Code Python Language Server crashes with JavaScript out of memory


I have a large Python project I'd like to edit in Visual Studio Code.

However, the Python Language server keeps crashing with JavaScript out of memory errors, like one below.

How can I increase the memory available for Pylance?

This is a local macOS project.


Solution

  • By default, Pylance is limited by the memory available to Visual Studio Code Electron application. It is troublesome to change this.

    However Pylance has an option to launch itself in an external Node.js process for which you can set the max heap size.

    This is available through Visual Studio Code settings. See the example settings below.

    enter image description here