Skip to content

F# sidecar releases referenced entities on reload and trim, and budgets swapped-out heap (#566) - #620

Open
MelbourneDeveloper wants to merge 2 commits into
mainfrom
fix/566-fsharp-entity-cache-leak
Open

MelbourneDeveloper wants to merge 2 commits into
mainfrom
fix/566-fsharp-entity-cache-leak

Conversation

@MelbourneDeveloper

Copy link
Copy Markdown
Collaborator

Problem

An installed F# sidecar held 2.4 GB after a 13-hour session on this repository (4 F# projects, 23 workspace reloads). A heap dump showed 1.56 GB live and 17 compiler import tables for 4 project builders.

Two defects, both in SharpLsp's F# sidecar (not lspkit: the retained graph is FSharpSidecar → FSharpWorkspaceState → EntityCache → AssemblySymbol → FSharpEntity → SymbolEnv → TcImports):

  1. Entity cache never cleared. FSharpWorkspaceState.Entities caches each referenced assembly's FCS symbols by file name. Each symbol holds the import tables of the build that made it, and neither a workspace reload nor a budget trim cleared the cache, so it pinned every build the session ever had.
  2. Budget measured swappable memory. The watchdog read WorkingSet64 only. macOS had compressed/swapped the idle sidecar to 141 MB resident while the collector had 2.17 GB committed, so the 2 GB soft limit never tripped.

Fix

  • A reload, an empty-workspace clear and a budget trim clear the entity cache.
  • The budget measures the larger of the resident set and the collector's committed heap.
  • [SIDECAR-PROCESS-MEMORY] updated to say both.

Tests

  • New: a reload and a trim release the referenced entities of the build they replace — failed before the fix ("the reload emptied the entity cache"), passes after; it also proves with a weak reference that nothing else pins the replaced build's entities.
  • F# sidecar suite: 585 passed. make _lint-dotnet: 0 warnings.

Refs #566 (stays open until verified on released binaries).

…ts swapped-out heap (#566)

The entity cache kept FCS symbols across workspace reloads; each holds the import
tables of the build that made it, so a long session pinned every build it ever had
(17 import tables for 4 projects, 1.5 GB live after 23 reloads). A reload and a
budget trim now clear it.

The memory budget read the resident set alone, which the OS compresses or swaps for
an idle sidecar (141 MB resident for 2.2 GB committed), so it never tripped. It now
reads the larger of the resident set and the collector's committed heap.
@MelbourneDeveloper
MelbourneDeveloper enabled auto-merge (squash) November 20, 2026 11:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant