Skip to content

Commit 20af107

Browse files
committed
Add garbage collection on shutdown.
1 parent 1ff9d6a commit 20af107

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

RetailCoder.VBE/Extension.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ private void ShutdownAddIn()
243243
_kernel = null;
244244
}
245245

246+
Debug.WriteLine("Extension: Initiating garbage collection.");
247+
248+
GC.Collect();
249+
250+
Debug.WriteLine("Extension: Initiated garbage collection.");
251+
252+
GC.WaitForPendingFinalizers();
253+
254+
Debug.WriteLine("Extension: Finalizers have run.");
255+
246256
_isInitialized = false;
247257
}
248258

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ private void ParseAll(object requestor, CancellationToken token)
320320
if (watch != null && watch.IsRunning) watch.Stop();
321321
if (lockTaken) Monitor.Exit(_parsingRunSyncObject);
322322
}
323-
if (watch != null) Logger.Debug("Parsing run finished after {0}s. (thread {1}).", watch.Elapsed.Seconds, Thread.CurrentThread.ManagedThreadId);
323+
if (watch != null) Logger.Debug("Parsing run finished after {0}s. (thread {1}).", watch.Elapsed.TotalSeconds, Thread.CurrentThread.ManagedThreadId);
324324
}
325325

326326
private void ParseAllInternal(object requestor, CancellationToken token)

Rubberduck.VBEEditor/WindowsApi/SubclassingWindow.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,18 @@ protected SubclassingWindow(IntPtr subclassId, IntPtr hWnd)
3939
AssignHandle();
4040
}
4141

42+
private bool _disposed = false;
4243
public void Dispose()
4344
{
45+
if (_disposed)
46+
{
47+
return;
48+
}
49+
4450
ReleaseHandle();
4551
_thisHandle.Free();
52+
53+
_disposed = true;
4654
}
4755

4856
private void AssignHandle()

0 commit comments

Comments
 (0)