THYGC

Overview

The THYGC class provides methods for obtaining information about the garbage collection system and for controlling some aspects of garbage collection. For more information please use this MSDN article.

Use Case

You can get access to an instance of this class via global THYClr object. Please note that using this class can affect performance of an application.

uses
  uHYCLRWrappers;

if HYClr <> nil then
  HYClr.GC.Collect(-1);

Location

  • Unit: Hydra.Managed.Wrappers.pas
  • Ancestry: THYGC

Properties


GC

Reference to a Microsoft GC interface.

property GC: IGCHost read

Instance Methods


constructor Create

Creates a new instance of the object.

constructor Create

Collect

Forces a collection to occur for the given generation, regardless of the state of the current garbage collection.

procedure Collect(Generation: Integer)

Parameters:

  • Generation: The generation on which to perform the garbage collection. A value of -1 indicates that all generations will undergo a garbage collection.

GetStats

Gets the statistics for the current state of the garbage collection system.

function GetStats: _COR_GC_STATS

GetThreadStats

Gets the per-thread statistics for garbage collection.

procedure GetThreadStats(var FiberCookie: LongWord; var Stats: _COR_GC_THREAD_STATS)

Parameters:

  • FiberCookie: A pointer to a fiber cookie that specifies the thread for which to retrieve the statistics.
  • Stats: A reference to a COR_GC_THREAD_STATS structure that contains the garbage collection statistics for the specified thread.