Do user have control over garbage collection in .NET? RRS feed

  • Question

  • Since we know that CLR does the garbage collection automatically, whether user can take control over garbage collection. I ran into a discussion regrading this when my instructor told that users don't have control on garbage collection but i know that finalize methods and collect() method in System.GC gives users some control on garbage collector.
    Saturday, August 11, 2012 2:54 PM


  • You have some degree of control over it.  See the System.GC class.  You can call GC.Collect(), for example, to force garbage collection if you have a strong reason to do so.

    Jose R. MCP
    Code Samples

    • Proposed as answer by MasaSam Sunday, August 12, 2012 6:39 AM
    • Marked as answer by Mike FengModerator Wednesday, August 22, 2012 2:54 PM
    Saturday, August 11, 2012 4:18 PM