From c93af8821f7de11349f65e19ea8f923ccae7bd8d Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Tue, 13 Nov 2018 10:13:07 -0600 Subject: [PATCH] Added memory debug, removed GC call for #170 --- GBM/Forms/frmMain.vb | 12 +++++++++--- GBM/My Project/Resources.Designer.vb | 18 ++++++++++++++++++ GBM/My Project/Resources.resx | 6 ++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index d42120a..839b4dd 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -45,6 +45,7 @@ Public Class frmMain 'Developer Debug Flags Private bProcessDebugMode As Boolean = False + Private bMemoryDebugMode As Boolean = False WithEvents oFileWatcher As New FileSystemWatcher @@ -842,6 +843,11 @@ Public Class frmMain Case "process" bProcessDebugMode = bDebugEnable mgrCommon.ShowMessage(frmMain_CommandSucess, MsgBoxStyle.Exclamation) + Case "memory" + bMemoryDebugMode = bDebugEnable + mgrCommon.ShowMessage(frmMain_CommandSucess, MsgBoxStyle.Exclamation) + Case Else + mgrCommon.ShowMessage(frmMain_ErrorInvalidMode, New String() {sCommand(1), sCommand(0)}, MsgBoxStyle.Exclamation) End Select Case Else @@ -1972,9 +1978,9 @@ Public Class frmMain End If End If - 'When GBM is running on Mono (v5.16.0.179) a memory leak occurs. This does not occur on Windows. - 'See https://github.com/MikeMaximus/gbm/issues/170 for more details. - If mgrCommon.IsUnix Then GC.Collect() + If bMemoryDebugMode Then + UpdateLog(mgrCommon.FormatString(frmMain_DebugMemoryAllocation, Math.Round(GC.GetTotalMemory(False) / 1000000, 2)), False, ToolTipIcon.Info, True) + End If End Sub Private Sub bwMonitor_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles bwMonitor.DoWork diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index ef084d2..6fcbe49 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -3039,6 +3039,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Memory Allocation: [PARAM] MB. + ''' + Friend ReadOnly Property frmMain_DebugMemoryAllocation() As String + Get + Return ResourceManager.GetString("frmMain_DebugMemoryAllocation", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Game Backup Monitor Log. ''' @@ -3237,6 +3246,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Invalid mode([PARAM]) for command [PARAM].. + ''' + Friend ReadOnly Property frmMain_ErrorInvalidMode() As String + Get + Return ResourceManager.GetString("frmMain_ErrorInvalidMode", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to The command [PARAM] requires more parameters.. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index f37fc8b..09d9227 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2275,4 +2275,10 @@ Recurse sub-folders + + Memory Allocation: [PARAM] MB + + + Invalid mode([PARAM]) for command [PARAM]. + \ No newline at end of file