Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 146731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:39:20+00:00 2026-05-11T08:39:20+00:00

I am trying to find a way to know about garbage collection. Either, when

  • 0

I am trying to find a way to know about garbage collection. Either, when it has started, finished or is in process. I really just need some event connected to the collection itself (I think).

My issue is that I have a WeakEventManager (written from scratch) and I have cleanup methods that delete and WeakReferences that are no longer alive (WeakReferences are in a Dictionary).

The issue is that I have to know when it is time to ‘clean up’. It would be nice to cleanup when the collector is doing its thing. Even if it is after the garbage collection, at least the next collection will remove these old objects.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:39:21+00:00Added an answer on May 11, 2026 at 8:39 am

    Here’s the class I used to log to SmartInspect that GC has occured. You should easily be able to change what this class does.

    To get it started, simply call GCLog.Register();.

    #region File Header // This file Copyright © 2007 Lasse Vågsæther Karlsen, All rights reserved. // // $Id: GCLog.cs 135 2008-05-28 11:28:37Z lassevk $ #endregion  #region Using  using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using Gurock.SmartInspect;  #endregion  namespace PresentationMode {     /// <summary>     /// This class is used to get a running log of the number of garbage collections that occur,     /// when running with logging.     /// </summary>     public sealed class GCLog     {         #region Construction & Destruction          /// <summary>         /// Releases unmanaged resources and performs other cleanup operations before the         /// <see cref='GCLog'/> is reclaimed by garbage collection.         /// </summary>         ~GCLog()         {             SiAuto.Main.LogMessage('GARBAGE COLLECTED');             if (!AppDomain.CurrentDomain.IsFinalizingForUnload() && !Environment.HasShutdownStarted)                 new GCLog();         }          #endregion          #region Public Static Methods          /// <summary>         /// Registers this instance.         /// </summary>         public static void Register()         { #if DEBUG             if (SiAuto.Si.Enabled)                 new GCLog(); #endif         }          #endregion     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.