[Mono-dev] New performance counter in Mono to report physical memory size in the machine

Jay R. Wren jrwren at xmtp.net
Sun Apr 18 08:00:04 EDT 2010


Confirmed, the constructor throws InvalidOperationException with a
message of "Category does not exist." on .NET 4.

The code you pasted falls through to "Cannot detect Physical RAM".

It is not a big deal, but it is something of which people should be aware.
--
Jay

On 4/17/2010 10:14 PM, jmalcolm wrote:
> Thanks Marek,
>
> Does this live in System.Diagnostics?
>
> Does this mean that the code you posted would fail on Microsoft.NET with an
> InvalidOperationException?
>
> System.Diagnostics seems like the place Microsoft should have put it.  I am
> just surprised to see a Mono extension that does not have it's own assembly
> or namespace.  There are probably more that I have managed to miss or simply
> forgotten about.
>
> Would something like the following be portable?
>
> --- CUT ---
> using System;
> using System.Diagnostics;
>
> class app
> {
>    static void Main ()
>    {
>        if (PerformanceCounterCategory.Exists("Mono Memory"))
>        {
>             var pc = new PerformanceCounter ("Mono Memory", "Total Physical
> Memory");
>             Console.WriteLine ("Physical RAM (bytes): {0}", pc.RawValue);
>        }
>        else
>        {
>             Console.WriteLine("Cannot detect physical RAM");
>        }
>    }
> }
> --- CUT ---
>
> Sorry if this is a basic question but I am currently on a Windows machine. 
> Building Mono from trunk on Windows is not an area of strength for me and I
> have not really played around with this part of the framework before.
>   



More information about the Mono-devel-list mailing list