mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
feat: add total memory usage to dev bar
This commit is contained in:
parent
29a39b4be1
commit
1083c2f95e
3 changed files with 21 additions and 19 deletions
|
|
@ -714,6 +714,7 @@ namespace Dalamud.Interface.Internal
|
|||
ImGui.BeginMenu(Util.GetGitHash(), false);
|
||||
ImGui.BeginMenu(this.frameCount.ToString(), false);
|
||||
ImGui.BeginMenu(ImGui.GetIO().Framerate.ToString("F2"), false);
|
||||
ImGui.BeginMenu($"{Util.FormatBytes(GC.GetTotalMemory(false))} total managed", false);
|
||||
|
||||
ImGui.EndMainMenuBar();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using Dalamud.Interface.Colors;
|
|||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows
|
||||
|
|
@ -197,24 +198,6 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
this.DrawSaveCloseButtons();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transform byte count to human readable format.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Number of bytes.</param>
|
||||
/// <returns>Human readable version.</returns>
|
||||
private static string FormatBytes(long bytes)
|
||||
{
|
||||
string[] suffix = { "B", "KB", "MB", "GB", "TB" };
|
||||
int i;
|
||||
double dblSByte = bytes;
|
||||
for (i = 0; i < suffix.Length && bytes >= 1024; i++, bytes /= 1024)
|
||||
{
|
||||
dblSByte = bytes / 1024.0;
|
||||
}
|
||||
|
||||
return $"{dblSByte:0.##} {suffix[i]}";
|
||||
}
|
||||
|
||||
private void DrawGeneralTab()
|
||||
{
|
||||
ImGui.Text(Loc.Localize("DalamudSettingsLanguage", "Language"));
|
||||
|
|
@ -351,7 +334,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
|
||||
ImGuiHelpers.ScaledDummy(12);
|
||||
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, "Total memory used by Dalamud & Plugins: " + FormatBytes(GC.GetTotalMemory(false)));
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, "Total memory used by Dalamud & Plugins: " + Util.FormatBytes(GC.GetTotalMemory(false)));
|
||||
}
|
||||
|
||||
private void DrawCustomReposSection()
|
||||
|
|
|
|||
|
|
@ -335,6 +335,24 @@ namespace Dalamud.Utility
|
|||
if (exit)
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transform byte count to human readable format.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Number of bytes.</param>
|
||||
/// <returns>Human readable version.</returns>
|
||||
public static string FormatBytes(long bytes)
|
||||
{
|
||||
string[] suffix = { "B", "KB", "MB", "GB", "TB" };
|
||||
int i;
|
||||
double dblSByte = bytes;
|
||||
for (i = 0; i < suffix.Length && bytes >= 1024; i++, bytes /= 1024)
|
||||
{
|
||||
dblSByte = bytes / 1024.0;
|
||||
}
|
||||
|
||||
return $"{dblSByte:0.##} {suffix[i]}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a UTF8 string from a null terminated byte array.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue