Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

PerformanceCounterCategory

Discussion in 'Windows' started by mite51, Apr 28, 2019.

  1. mite51

    mite51

    Joined:
    Jun 25, 2015
    Posts:
    13
    Hello,

    I'm trying to determine the system wide GPU usage per application on Windows using this code:
    Code (CSharp):
    1.                 PerformanceCounterCategory cat = new PerformanceCounterCategory("GPU Engine");
    2.                 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?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,516
    I don't think we support these APIs in Unity.
     
  3. mite51

    mite51

    Joined:
    Jun 25, 2015
    Posts:
    13
    Unfortunate, but expected I guess. I've already started a DLL to import that will supply the functionality from C++.
     
  4. calebbbarton

    calebbbarton

    Joined:
    Mar 20, 2018
    Posts:
    11
    Did you ever get this working in Unity? I'm interested in reading available RAM on a device, and am running into roadblocks