# Language Services

IntelliJ IDEA relies on TypeScript, Vue, Astro, Svelte, and other framework-specific language services to provide autocompletion, code analysis, and error highlighting.

## Configure memory handling

Although IntelliJ IDEA strives at providing slick integration with language services, there may still arise out-of-memory errors induced by a language service rather than by IntelliJ IDEA itself.

### Memory handling modes

When a language service runs out of memory, IntelliJ IDEA first attempts to restart it. After two sequential attempts fail, the language service stops and IntelliJ IDEA indicates the error in the Language Services widget on the status bar and displays a popup with an error message.

To prevent out-of-memory errors or have them solved seamlessly, thus ensuring stable operation of language services, you can configure memory handling in the following two modes:

#### Increase memory automatically

In this mode, IntelliJ IDEA automatically adds 1000MB when an out-of-memory error is to occur and restarts the language service in the background.

IntelliJ IDEA continues silently with this approach until the maximum memory limit of 25% RAM is reached, whereupon the language service stops and IntelliJ IDEA displays a popup with an error message.

For information on possible steps to improve the situation, refer to [Troubleshooting](#ls_troubleshooting).

#### Set memory limit

In this mode, you manually specify maximum memory a language service can use. Until this limit is reached, IntelliJ IDEA suggests adding 1000MB on each out-of-memory error.

When the specified limit is reached, the language service stops and IntelliJ IDEA displays a popup with an error message.

For information on possible steps to improve the situation, refer to [Troubleshooting](#ls_troubleshooting).

### Configure memory handling for TypeScript language service

> **Note:**
> Memory handling settings for Vue, Svelte, Astro, and other language services are always inherited from the TypeScript language service.

Procedure:

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Settings | Languages & Frameworks | Language Services | TypeScript`.

2. In the Language Services Memory area, choose the memory handling mode:

* Select Automatically increase memory, if available to have memory increased and language services restarted silently.

* Alternatively, select Set memory limit and specify the maximum memory to use by a language service. If the specified memory size exceeds the available RAM, IntelliJ IDEA suggests an appropriate value in a tooltip. > **Note:** > Make sure your computer has enough available RAM. If you are already at a high allocation, for example, 8GB+, consider [upgrading/downgrading](#ls_upgrade_downgrade) or [limiting your > project scope](#ls_limit_project_scope).

## Troubleshooting

An out-of-memory error occurs when a language service exceeds its allocated memory limit and can no longer handle the workload. This typically happens for the following reasons:

* The project you are currently working with contains a large number of files and dependencies.

* The maximum memory limit specified in the IDE settings is not enough for a language service.

Procedure: Increase memory allocation

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Settings | Languages & Frameworks | Language Services | TypeScript`.

2. Select the Set memory limit option.

3. Increase the limit gradually, for example, from 4GB to 6GB and then to 8GB. Monitor the improvements.

Procedure: Limit your project scope

Large projects with excessive files or dependencies can overload a language service. To reduce the load in large codebases, follow the recommendations from the [performance guide](https://github.com/microsoft/Typescript/wiki/Performance) provided by the TypeScript team, especially the sections [Using
Project References](https://github.com/microsoft/Typescript/wiki/Performance#using-project-references) and [Configuring tsconfig.json or jsconfig.json](https://github.com/microsoft/Typescript/wiki/Performance#configuring-tsconfigjson-or-jsconfigjson).

> **Note:**
> The recommended practices are applicable to projects that use the TypeScript language service itself as well as to projects with Vue, Astro, and Svelte frameworks, that also rely on the TypeScript language service.

Procedure: Upgrade or downgrade

* Make sure you are using an up-to-date version of a language service.

IntelliJ IDEA is shipped with bundled versions of language services. However, newer versions of language services often include performance improvements. Therefore, it is recommended that you keep language services up to date.

To install the latest version of a language service,    open your command-line shell or  the embedded Terminal (`Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `Alt+F12` (NetBeans), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS)))  and type one of the following depending on the language service and the package manager you are using:

TypeScript:

```SHELL
npm install --save-dev typescript
```

or

```SHELL
pnpm add --save-dev typescript
```

or

```SHELL
yarn add --dev typescript
```

Vue:

```SHELL
npm install --save-dev @vue/language-server
```

or

```SHELL
pnpm add --save-dev @vue/language-server
```

or

```SHELL
yarn add --dev @vue/language-server
```

Svelte:

```SHELL
npm install --save-dev svelte-language-server typescript-svelte-plugin
```

or

```SHELL
pnpm add --save-dev svelte-language-server typescript-svelte-plugin
```

or

```SHELL
yarn add --dev svelte-language-server typescript-svelte-plugin
```

Astro:

```SHELL
npm install --save-dev @astrojs/language-server
```

or

```SHELL
pnpm add --save-dev @astrojs/language-server
```

or

```SHELL
yarn add --dev @astrojs/language-server
```

* If an issue appeared after a language service update, consider downgrading to the previous version to confirm whether the problem was introduced by the update.

Procedure: Submit an issue in the IntelliJ IDEA issue tracker

If the problem persists, submit an issue in the [IntelliJ IDEA issue tracker](https://youtrack.jetbrains.com/issues/IDEA) and attach your project to it. This will help us reproduce and investigate the issue more efficiently.

