开发者

Tools to find boxing in code

开发者 https://www.devze.com 2023-03-14 17:12 出处:网络
Background: I\'m developing for the xbox and am at the optomising stage. I need to cut down on object allocations. One place to start is finding out where (un)boxing occurs.

Background: I'm developing for the xbox and am at the optomising stage. I need to cut down on object allocations. One place to start is finding out where (un)boxing occurs.

I'm very new to IL (in that i've never looked at any!) and would like to avoid running DLLs through a dissassembler, hunting for the (un)box command then trying to work out what line of code it relates to.

Question:开发者_Go百科 Are there any tools which will report this kind of thing (where (un)boxing occurs) for me?

EDIT: Made request below into its own question since it's fairly distinct from this one.

Many, many, bonus points for a way of tieing a GC heap dump back to lines of code where the object creations occured!!


This MSDN Magazine article details how to create an FxCop (Code Analysis) rule that detects boxing and unboxing and can present violations as a warning. The article is a little on the old side, but you should be able to adapt it to your needs.


There is a tool called BoxCop which does exactly that.

It is not really useful when trying to integrate the checks for boxing/unboxing into the build process. For that you would need some rule for FxCop.

0

精彩评论

暂无评论...
验证码 换一张
取 消