Skip to content

[JIT] Questions & suggestions regarding escape analysis and heap allocation analyzers #131676

Description

@diegoxd12wee436

Hi everyone,

I'm a CS student, not a professional developer, so I don't know all the deep technical details of how the compiler works. C# is my favorite language — I find it much easier to read and write than C++ or Rust, which honestly give me a headache.

But I know C# has one disadvantage in performance-critical fields (robotics, real-time systems, high-frequency trading): the Garbage Collector can cause small pauses that C++ doesn't have.

I found out there used to be tools for this:

RoslynClrHeapAllocationAnalyzer: a Microsoft tool that warned about heap allocations (archived in 2022).
HotPathAllocationAnalyzer: a community project that picked up the idea and added an attribute to mark a method as "no allocations allowed here."
My question/idea: would it make sense for Microsoft to officially bring back and maintain a tool like this? Not a change to the language itself — just a build-time analyzer that tells you "hey, this line will allocate memory, are you sure?" for people writing performance-critical C#.

I know C# probably won't fully replace C++ or Rust in every case, but I think small steps like this could help close the gap in scenarios where it matters. Sorry if this has already been discussed somewhere — I'm still learning and happy to be pointed to existing conversations!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions