How to interpret the performance counter "# of Methods Jitted"?

When I tried to reproduce the reported problem with a managed nt service, I noticed that the performance counter "# of Methods Jitted" is constantly growing (along with "# of IL Bytes Jitted"). The reported behavior is that it takes up a lot of memory (not necessarily everything that is available on the machine) and consumes a 100% processor. Requests for this nt service (via wcf) often lead to timeouts, that is, to 90 seconds. (Requests start at asp.net on the same computer.)

After a 15-minute warm-up, the value was 127k (3610 kb) and 246k (6427 kb) after an hour, that is, an increase of 119 k jitted methods.

I don’t think this is just the one behavior that caused the problem to be reported, because the reported runtime before the service goes into chaos is only a few hours.

However, I'm still interested in how to interpret this [seemingly] ever-growing number. Although it is only 3 mb / h, it will be 500 mb per week. And also, does anyone know if "No. IL Bytes Jitted" is a garbage collection item?

(Within 20 minutes of writing this post, the number of methods increased by 33k and the number of bytes from ~ 300k.)

Explanation
Things I should have mentioned for the first time ...;)

  • We do not have code that creates, downloads or unloads any applications.
  • We do not emit anything and use C # 3, therefore there are no dynamic objects.
  • We use NHibernate and AutoMapper, using reflection to solve our problems. However, I believe that these libraries behave well and do not cause this behavior. (Any tool that lets me see which methods are shorted?)

Changes

  • Deletes the comparison between the number of lines of code and the number of jitted methods. As Oded points out, the counter also includes methods in the .NET Framework.
+4
source share
2 answers

There may be a number of reasons why the process will continue to jitting code. If you load assemblies into specific AppDomains, the same methods will be redrawn if you load assemblies into another AppDomain (unless assemblies are loaded as neutral for the domain).

Generating and running dynamic methods will also bias all new methods.

Regarding garbage collection. GC only clears a bunch of managed objects. Jitted code is stored in the AppDomain heap of code and therefore is not collected by the GC. Unloading AppDomain will get rid of a bunch of code for this domain.

This post contains additional information http://blogs.msdn.com/cbrumme/archive/2003/06/01/51466.aspx

Update: Regarding Tools

WinDbg + Sos will show you which methods were created for each type. Use !dumpmt -md . You can also see which modules are loaded into each AppDomain with the !dumpdomain . However, it will probably take a little time to find the parts you are looking for.

+3
source

The number of lines interconnected includes a framework and third-party library code.

These are not C #, VB.NET strings, but CIL strings that contain more strings β€” this may be enough to account for the mismatch.

+1
source

Source: https://habr.com/ru/post/1302484/


All Articles