From 92fb1bf624ee5d4e1d94f11c6472478cf69e5efc Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Thu, 9 Jan 2020 16:22:28 -0500 Subject: [PATCH] Fixed diagnostics data provider memory limit reporting (#438) * Fixed the issue with the diagnostics data provider not reporting the correct memory limit * A bit cleaner --- ...MixedRealityMemoryDiagnosticsDataProvider.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Services/DiagnosticsSystem/MixedRealityMemoryDiagnosticsDataProvider.cs b/Services/DiagnosticsSystem/MixedRealityMemoryDiagnosticsDataProvider.cs index ff4d38f1c..6bdb45faa 100644 --- a/Services/DiagnosticsSystem/MixedRealityMemoryDiagnosticsDataProvider.cs +++ b/Services/DiagnosticsSystem/MixedRealityMemoryDiagnosticsDataProvider.cs @@ -1,7 +1,6 @@ // Copyright (c) XRTK. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. -using UnityEngine; using UnityEngine.Profiling; using XRTK.Definitions.DiagnosticsSystem; @@ -23,8 +22,6 @@ public MixedRealityMemoryDiagnosticsDataProvider(string name, uint priority, Mix { } - private int systemMemorySize; - private int lastSystemMemorySize; private ulong lastMemoryUsage; private ulong peakMemoryUsage; private ulong lastMemoryLimit; @@ -36,18 +33,14 @@ public override void LateUpdate() { base.LateUpdate(); - systemMemorySize = SystemInfo.systemMemorySize; + var systemMemorySize = (ulong)Profiler.GetTotalReservedMemoryLong(); - if (lastSystemMemorySize != systemMemorySize) + if (lastMemoryUsage != systemMemorySize) { - lastSystemMemorySize = systemMemorySize; - - var currentMemoryLimit = DiagnosticsUtils.ConvertMegabytesToBytes(lastSystemMemorySize); - - if (currentMemoryLimit != lastMemoryLimit) + if (systemMemorySize > lastMemoryLimit) { - MixedRealityToolkit.DiagnosticsSystem.RaiseMemoryLimitChanged(new MemoryLimit(currentMemoryLimit)); - lastMemoryLimit = currentMemoryLimit; + MixedRealityToolkit.DiagnosticsSystem.RaiseMemoryLimitChanged(new MemoryLimit(systemMemorySize)); + lastMemoryLimit = systemMemorySize; } }