Skip to content

Commit

Permalink
Should Fix #3689
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Aug 7, 2023
1 parent 2f53355 commit f2ec02c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions patches/tModLoader/Terraria/ModLoader/Core/MemoryTracking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ internal static void Finish()
.Where(val => val != null)
.Sum(sound => (long)sound.Duration.TotalSeconds * 44100 * 2 * 2);
}
long totalRamUsage = Process.GetProcesses().Sum(x => x.WorkingSet64);
Logging.tML.Info($"RAM: tModLoader usage: {UIMemoryBar.SizeSuffix(Process.GetCurrentProcess().WorkingSet64)}, All processes usage: {UIMemoryBar.SizeSuffix(totalRamUsage)}, Available: {UIMemoryBar.SizeSuffix(UIMemoryBar.GetTotalMemory() - totalRamUsage)}, Total Installed: {UIMemoryBar.SizeSuffix(UIMemoryBar.GetTotalMemory())}");
long totalRamUsage = -1;
try {
totalRamUsage = Process.GetProcesses().Sum(x => x.WorkingSet64); // Might throw UnauthorizedAccessException on locked down Linux systems. See https://github.com/tModLoader/tModLoader/issues/3689
}
catch { }
Logging.tML.Info($"RAM: tModLoader usage: {UIMemoryBar.SizeSuffix(Process.GetCurrentProcess().WorkingSet64)}, All processes usage: {(totalRamUsage == -1 ? "Unknown" : UIMemoryBar.SizeSuffix(totalRamUsage))}, Available: {UIMemoryBar.SizeSuffix(UIMemoryBar.GetTotalMemory() - totalRamUsage)}, Total Installed: {UIMemoryBar.SizeSuffix(UIMemoryBar.GetTotalMemory())}");
}
}

0 comments on commit f2ec02c

Please sign in to comment.