Collect() public method

Go through the collection of callback wrappers and remove any dead callbacks.
public Collect ( ) : void
return void
        public void VerifyCallbackWrappersCollectsUnusedWrappers()
        {
            DateTime endTime = DateTime.Now + TimeSpan.FromSeconds(19);

            var callbackWrappers = new CallbackWrappers();

            RunFullGarbageCollection();
            long memoryAtStart = GC.GetTotalMemory(true);

            while (DateTime.Now < endTime)
            {
                for (int i = 0; i < 128; ++i)
                {
                    CreateCallbackWrapper(callbackWrappers);
                }

                RunFullGarbageCollection();
                callbackWrappers.Collect();
                RunFullGarbageCollection();
            }

            RunFullGarbageCollection();
            long memoryAtEnd = GC.GetTotalMemory(true);
            GC.KeepAlive(callbackWrappers);

            long memory = memoryAtEnd - memoryAtStart;
            Console.WriteLine("{0:N0} bytes used", memory);
            Assert.IsTrue(memory < 1024 * 1024, "Test used too much memory. JetCallbackWrapper objects weren't collected.");
        }
        public void VerifyWrapperIsCollectedWhenCallbackIsCollected()
        {
            JET_CALLBACK callback = CreateCallback();
            var callbackRef = new WeakReference(callback);

            var callbackWrappers = new CallbackWrappers();
            var wrapperRef = new WeakReference(callbackWrappers.Add(callback));

            callback = null;

            RunFullGarbageCollection();
            callbackWrappers.Collect();
            RunFullGarbageCollection();

            Assert.IsFalse(callbackRef.IsAlive);
            Assert.IsFalse(wrapperRef.IsAlive);

            // Avoid premature collection of this objects
            GC.KeepAlive(callbackWrappers);
        }