facebook / facebook/pyrefly

Pyrefly consumes A LOT of memory

Open
#3,466 6 comments 0 reactions 1 assignee Claimed by @kinto0 View on GitHub
language-server performance stale
Dominant language
Rust
Stars
7k
Forks
519
PR merge metrics
No merged PRs in 30d

Description

## Pyrefly LSP consuming excessive RAM (~20 GB) with Neovim via lspconfig on large monorepo

**Environment**
- Editor: Neovim v0.11.5
- LSP client: `nvim-lspconfig`
- LSP server: `pyrefly v1.0.0`
- OS: macOS 26.5
- PC: MacBook Pro 14 M4 Pro (24GB RAM)
- Repo: large private Python/Django monorepo

---

### Description

When using `pyrefly` as an LSP server through `nvim-lspconfig` on a large monorepo,
memory consumption grows to extreme levels — we have observed up to **20 GB of RAM**
in use by the pyrefly process as seen in macOS Activity Monitor.

At that point the system is forced to use **swap memory**, causing noticeable disk
thrashing, and the fans ramp up significantly as the CPU works to keep up with
the thermal load.

### Steps to reproduce

1. Clone or open a large Python monorepo (hundreds of packages / thousands of files).
2. Configure `pyrefly` as an LSP server via `nvim-lspconfig`.
3. Open any Python file and wait for pyrefly to index the project.
4. Monitor memory usage in Activity Monitor (macOS) or equivalent.

### Expected behavior

Memory usage should stay within a reasonable bound regardless of repo size — other
Python LSP servers (e.g. `pyright`, `basedpyright`) index the same codebase without
approaching anywhere near this level of RAM consumption.

### Actual behavior

The `pyrefly` process grows continuously until it consumes **~20 GB of RAM**, pushing
the system into swap and causing fan noise from sustained thermal load.

### Additional context

- The issue appears to be related to full-project indexing with no apparent memory cap.
- The problem is reproducible consistently on this monorepo; smaller projects may not
trigger it.
- Workaround: killing the pyrefly process and relying on a different LSP server.
- We're using a `pyrefly.toml` file with 125 lines of excluded directories to avoid issues when indexing the project see #2039

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.