Skip to content

In latest release (0.3.2735) I got severe memory problems - related to proc macros #21382

@izderadicka

Description

@izderadicka

description:

With upgrading to latest release I started to experience severe memory issues with rust-analyzer server.

Before it took about 3-4 GB resident memory - which I considered OKish, as this is workspace project with several crates and frequent using of proc macros.

With upgrade now memory usage goes out of limits - to 11GB + until it consumes all memory on my Linux.

With disabling proc macros in setting, behaves OK with ~ 3 GB memory. Going one version down to .2727 resolves problem - so must have be something recent (tried also prerelease - same problem)

Project compiles OK - cargo check - no problems.

I see this output on rust-analyzer server:

2026-01-01T17:26:33.605253077+01:00  WARN cyclic deps: mbs4_macros(Idx::<CrateBuilder>(29)) -> mbs4_dal(Idx::<CrateBuilder>(24)), alternative path: mbs4_dal(Idx::<CrateBuilder>(24)) -> mbs4_macros(Idx::<CrateBuilder>(29))
2026-01-01T17:26:34.244014599+01:00  WARN cyclic deps: mbs4_macros(Idx::<CrateBuilder>(29)) -> mbs4_dal(Idx::<CrateBuilder>(24)), alternative path: mbs4_dal(Idx::<CrateBuilder>(24)) -> mbs4_macros(Idx::<CrateBuilder>(29))
[Error - 5:26:58 PM] Server process exited with signal SIGKILL.
[Info  - 5:26:58 PM] Connection to server got closed. Server will restart.
true
2026-01-01T17:27:01.093299562+01:00  WARN cyclic deps: mbs4_macros(Idx::<CrateBuilder>(29)) -> mbs4_dal(Idx::<CrateBuilder>(24)), alternative path: mbs4_dal(Idx::<CrateBuilder>(24)) -> mbs4_macros(Idx::<CrateBuilder>(29))
2026-01-01T17:27:02.060325441+01:00  WARN cyclic deps: mbs4_macros(Idx::<CrateBuilder>(29)) -> mbs4_dal(Idx::<CrateBuilder>(24)), alternative path: mbs4_dal(Idx::<CrateBuilder>(24)) -> mbs4_macros(Idx::<CrateBuilder>(29))
[Error - 5:27:24 PM] Server process exited with signal SIGKILL.
[Error - 5:27:24 PM] The Rust Analyzer Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

I had to add VS Code to cgroups, with memory limit to be able to test - so that's the SIGKILL - when rust-analyzer grows over 6GB.

On previous version .2727 it works fine - log has same warnings, but memory stops on 3.3 gigs.
Log:

2026-01-01T17:51:30.453472898+01:00  WARN cyclic deps: mbs4_macros(Idx::<CrateBuilder>(29)) -> mbs4_dal(Idx::<CrateBuilder>(24)), alternative path: mbs4_dal(Idx::<CrateBuilder>(24)) -> mbs4_macros(Idx::<CrateBuilder>(29))
2026-01-01T17:51:31.161244567+01:00  WARN cyclic deps: mbs4_macros(Idx::<CrateBuilder>(29)) -> mbs4_dal(Idx::<CrateBuilder>(24)), alternative path: mbs4_dal(Idx::<CrateBuilder>(24)) -> mbs4_macros(Idx::<CrateBuilder>(29))
2026-01-01T17:51:58.769892186+01:00  WARN overly long loop turn took 370.190971ms (event handling took 370.104714ms): PrimeCaches(End { cancelled: false })

It's quite nasty bug - took me quite some time to nail it down - hope you'll be able to fix as RA is key tool for me. I downgraded for now.

Thanks
Ivan

rust-analyzer version: 0.3.2735 - also tested on pre-realease - 0.4.2737 - same problem

rustc version: rustc 1.92.0 (ded5c06cf 2025-12-08)

editor or extension: VS Code - version 0.3.2735

relevant settings:
On Ubuntu 22.04 - rust installed standardly via rustup

repository link (if public, optional):mbs4)

code snippet to reproduce:
The memory growth is triggered by going to this code and saving - triggering analyzes on this.

use mbs4_macros::Repository;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Clone, Repository, sqlx::FromRow)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct Language {
    #[spec(id)]
    pub id: i64,
    #[garde(length(min = 1, max = 255))]
    pub name: String,
    #[garde(length(min = 2, max = 4))]
    pub code: String,
    #[garde(range(min = 0))]
    #[spec(version)]
    pub version: i64,
}

Metadata

Metadata

Labels

C-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions