controlflow / resharper-heapview

ReSharper Heap Allocations Viewer plugin
MIT License
303 stars 28 forks source link

Show allocations due to params modifier #57

Closed drewnoakes closed 1 year ago

drewnoakes commented 6 years ago

I don't know all the cases in which calling a method having a params parameter results in allocation, but at least some calls must do. I don't see any indication via this extension however.

void Foo(params object[] bar) { }

Foo(1); // shows boxing
Foo("Foo"); // no indication that object[] is allocated
Foo(); // does this allocate? probably not
controlflow commented 1 year ago

HeapView had this inspection originally, but it was broken for quite some time :(( Currently it works and handles all the related compiler optimizations (C# compiler uses System.Array.Empty<T>() if it's available, when no arguments passed to params parameter). image