百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

resharper-heapview

> 编程语言
开源

ReSharper 堆分配查看器插件

329 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

ReSharper 堆分配查看器插件

HeapAllocationViewer for Rider and ReSharper

This plugin statically analyzes C# code to find all local object allocations happening.

It can be used to reduce number of heap allocations in hot paths of your C# program.

Features

  • It can detect and visualize all boxing cases, including:
csharp
struct Boxing {
  void M(string a) {
    object obj = 42;                // implicit conversion Int32 ~> Object
    string path = a + '/' + obj;    // implicit conversion Char ~> Object
    int code = this.GetHashCode();  // non-overriden virtual method call on struct
    string caseA = E.A.ToString();  // the same, virtual call
    IComparable comparable = E.A;   // valuetype conversion to interface type
    Action action = this.M; // delegate from value type method
    Type type = this.GetType();     // GetType() call is always virtual
  }

  enum E { A, B, C }
}
  • It can visualize some hidden allocations happening in C#, including:
…
  • It can detect delegate instances allocation, ignoring cached delegates:
csharp
class Delegates {
  static void M(string s) {
    Action method = M;      // non-cached delegate from method group
    Action lambda = () => M("a");   // cached delegate from static lambda
    Action closure = () => M(s);    // non-cached lambda with closure 's'
  }

  void M() {
    Action generic = () => { };     // non-cached, lambda in generic method
    Action closure = () => M();  // non-cached, captures 'this' to closure
  }
}
  • It can detect closure ("display classes") creation points:
csharp
class Closures {
  IEnumerable StupidExample(string str) {
    // ();

    if (str.Length == 0) {
      return Enumerable.Empty();
    } else {
      //  x == '_');

      return Enumerable
        .Range(0, str.Length)
        .Select(count => // delegate instance allocation
          str.Substring(Math.Max(value, count)));
    }
  }
}

Notes

  • Please, avoid premature optimizations. Use this tool with care, only when it matters to reduce allocations count;
  • You can change default colors of highlightings in Visual Studio settings: go Tools - Settings - Fonts and colors and check colors for items "ReSharper HeapView Boxing" and "ReSharper HeapView Allocation";
  • You can change highlighting severity or search for all issues in project/solution as usual - via Alt+Enter menu over highlighting;
  • This plugin highly relies on Microsoft's implementation of C# compiler shipping with VS, it may produce false positives for other C# implementations like Mono C# compiler;
  • Plugin's changelog is here.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言