private static void updateUsedMemoryCounter(PdhCounterPathElement pathElement)
        {
            MEMORYSTATUSEX memStatus = new MEMORYSTATUSEX();
            if (Interop.Interop.GlobalMemoryStatusEx(memStatus))
            {
                ulong installedMemory = memStatus.ullTotalPhys / 1024 / 1024;
                PerformanceCounter usedMemCounter = pathElement.InstanceName == null ?
                   new PerformanceCounter(pathElement.ObjectName, pathElement.CounterName, true) :
                   new PerformanceCounter(pathElement.ObjectName, pathElement.CounterName, pathElement.InstanceName, true);

                var itr = _handler.GetPathElements(new List<string>() { "\\Memory\\Available MBytes" });
                var pe = itr.ElementAt(0);
                PerformanceCounter availMem = pathElement.InstanceName == null ?
                   new PerformanceCounter(pe.ObjectName, pe.CounterName, true) :
                   new PerformanceCounter(pe.ObjectName, pe.CounterName, pe.InstanceName, true);

                usedMemCounter.ReadOnly = false;
                usedMemCounter.RawValue = (long)(installedMemory - Convert.ToUInt64(availMem.NextValue()));
                usedMemCounter.Close();
            }
        }