PerformanceCounterCategory

Hello,

I’m trying to determine the system wide GPU usage per application on Windows using this code:

                PerformanceCounterCategory cat = new PerformanceCounterCategory("GPU Engine");
                string[] instances = cat.GetInstanceNames();

It compiles and executes but “instances” is always zero length, where as the identical code on a C# console app works fine. I’ve seen a post here that seems to only apply to older version of Unity, and they suggest changing the player setting for .net version to a “full” .net 2.0… I’m on 2018.3 and there are no longer similar options. I’ve also tried adding “/r:system.dll” (the dll the defines system.diagnostics.PerformanceCounterCategory) to csc.rsp which also compiles, but doesn’t change the behavior.

Does anyone know how I might get this to work?

I don’t think we support these APIs in Unity.

Unfortunate, but expected I guess. I’ve already started a DLL to import that will supply the functionality from C++.

Did you ever get this working in Unity? I’m interested in reading available RAM on a device, and am running into roadblocks