Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Fixed diagnostics data provider memory limit reporting (#438)
Browse files Browse the repository at this point in the history
* Fixed the issue with the diagnostics data provider not reporting the correct memory limit

* A bit cleaner
  • Loading branch information
StephenHodgson authored Jan 9, 2020
1 parent 1148950 commit 92fb1bf
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 92fb1bf

Please sign in to comment.