Если я выполняю этот кодКак исправить OutOfMemoryException для PerformanceCounterCategory.GetInstanceName
PerformanceCounterCategory cat = new PerformanceCounterCategory("Process");
var instances = cat.GetInstanceNames(); // OutOfMemoryException
я получаю OutOfMemoryException
Полный стек трассировки
A first chance exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll
System.OutOfMemoryException: An Exception of Type "System.OutOfMemoryException" occured.
at Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity)
at Microsoft.Win32.RegistryKey.GetValue(String name)
at System.Diagnostics.PerformanceMonitor.GetData(String item)
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item)
at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String machine, String category)
at System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(String categoryName, String machineName)
at WindowsFormsApplication5.Form1.button1_Click(Object sender, EventArgs e)
Это происходит только в x64 ехе, если я бегу тот же код под x86 работает. Есть идеи, как это решить?
ОС - Windows 8.1 x64, с ОЗУ 8 ГБ (это не проблема физической памяти).
Какая версия окон? – tolanj
И сколько свободной памяти у вас есть перед вызовом проблемы? – tolanj
@tolanj Я добавил некоторые данные –