Here, the class I used to log into SmartInspect that the GC happened. You can easily change what this class does.
To get started, just call GCLog.Register();.
#region File Header
#endregion
#region Using
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Gurock.SmartInspect;
#endregion
namespace PresentationMode
{
public sealed class GCLog
{
#region Construction & Destruction
~GCLog()
{
SiAuto.Main.LogMessage("GARBAGE COLLECTED");
if (!AppDomain.CurrentDomain.IsFinalizingForUnload() && !Environment.HasShutdownStarted)
new GCLog();
}
#endregion
#region Public Static Methods
public static void Register()
{
#if DEBUG
if (SiAuto.Si.Enabled)
new GCLog();
#endif
}
#endregion
}
}
source
share