# Resource monitor

> See which terminal, language server or extension is using CPU and memory.

The resource monitor samples Rexa, each terminal, each language server, the extension host and the file watchers once a second. It lives in the status bar.

## Status bar item

The item, a CPU icon, stays blank while everything is within budget. When something stays over budget for three samples in a row, the item names it, such as `Rexa 3.2G`.

Click the item for a popup with one section each for App, Terminals, Language servers, Extensions and Watchers. Rows show CPU and memory; watcher rows show events per second and how long `git status` takes. Hover a row for details.

## Actions

Rows over the critical budget get an action. Each one asks first; nothing runs on its own.

| Row             | Action    | What happens                                      |
| --------------- | --------- | ------------------------------------------------- |
| Terminal        | Stop      | Sends SIGTERM to its process. The tab stays open. |
| Language server | Restart   | Restarts the language servers.                    |
| Extension host  | Restart   | Reloads every extension.                          |

## Budgets

Each kind takes a `[warn, critical]` pair. CPU is a percentage of one core; memory is in GB.

| Kind        | CPU        | Memory    |
| ----------- | ---------- | --------- |
| `app`       | 70 / 150   | 1.5 / 3   |
| `terminal`  | 150 / 300  | 2 / 4     |
| `lsp`       | 100 / 200  | 2 / 4     |
| `extension` | 100 / 200  | 1.5 / 3   |

Watchers have `eventsPerSec` 200 / 1000 and `gitStatusMs` 2000 / 10000. Override any of them in settings:

```json [settings.json]
{
  "resources": {
    "terminal": { "cpu": [200, 400], "memoryGb": [4, 8] }
  }
}
```

## Hide the item

```json [settings.json]
{
  "status_bar": { "hidden": ["rexa.resource"] }
}
```
