Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are .NET 4.0 MemoryCache performance counters?

Where are .NET 4.0 MemoryCache performance counters?

I am looking for their name and I can't find any.

Thank you,

like image 847
Allan Xu Avatar asked Nov 18 '13 22:11

Allan Xu


People also ask

How does MemoryCache work C#?

In-Memory Cache is used for when you want to implement cache in a single process. When the process dies, the cache dies with it. If you're running the same process on several servers, you will have a separate cache for each server. Persistent in-process Cache is when you back up your cache outside of process memory.

How do I clear my MemoryCache default?

You can dispose the MemoryCache. Default cache and then re-set the private field singleton to null, to make it recreate the MemoryCache. Default.

Which of the following exception performance counters in dotnet framework?

Exception performance counters. The Performance console . NET CLR Exceptions category includes counters that provide information about the exceptions thrown by an application.


1 Answers

That's a loaded question with a very long answer. I doubt it is going to be helpful, let's talk about the real problem you are trying to solve. Those performance counters have to be registered first before you can see them.

Start an elevated console prompt (right-click the shortcut and use Run as Administrator) and type these commands:

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 lodctr netmemorycache.ini 

That adds the required registry entries so the MemoryCache can create these counters at runtime. Start your program so an instance of MemoryCache is created. Run Perfmon.exe, right-click the graph, Add Counters and pick from the added ".NET Memory Cache 4.0" category. Also select the instance of your program.

like image 118
Hans Passant Avatar answered Sep 28 '22 08:09

Hans Passant