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

Fixed diagnostics data provider memory limit reporting #438

Merged
merged 2 commits into from
Jan 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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