We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following code is causing large memory allocation:
ApplicationInsights-dotnet/WEB/Src/PerformanceCollector/Perf.Shared/Implementation/PerformanceCounterUtility.cs
Line 494 in 58618d7
Suggested improvement:
static readonly ConcurrentDictionary<string, Tuple<DateTime, PerformanceCounterCategory, InstanceDataCollectionCollection>> cache = new ConcurrentDictionary<string, Tuple<DateTime, PerformanceCounterCategory, InstanceDataCollectionCollection>>(); private static string FindProcessInstance1(int pid, IEnumerable<string> instances, string categoryName, string counterName) { Tuple<DateTime, PerformanceCounterCategory, InstanceDataCollectionCollection> cached; DateTime utcNow = DateTime.UtcNow; InstanceDataCollectionCollection result = null; PerformanceCounterCategory category = null; if (cache.TryGetValue(categoryName, out cached)) { category = cached.Item2; if (cached.Item1 < utcNow) { result = cached.Item3; } } if (result == null) { if (category == null) { category = new PerformanceCounterCategory(categoryName); } result = category.ReadCategory(); cache.TryAdd(categoryName, new Tuple<DateTime, PerformanceCounterCategory, InstanceDataCollectionCollection>(utcNow.AddMinutes(1), category, result)); } InstanceDataCollection counters = result[counterName]; if (counters != null) { foreach (string i in instances) { InstanceData instance = counters[i]; if ((instance != null) && (pid == instance.RawValue)) { return i; } } } return null; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The following code is causing large memory allocation:
ApplicationInsights-dotnet/WEB/Src/PerformanceCollector/Perf.Shared/Implementation/PerformanceCounterUtility.cs
Line 494 in 58618d7
Suggested improvement:
The text was updated successfully, but these errors were encountered: