Skip to main content
Version: v1

IGarbageCollectionRuntime Interface

Defines the APIs for the runtime object to be passed to the garbage collector.

Signature​

export interface IGarbageCollectionRuntime

Methods​

MethodReturn TypeDescription
closeFn(error)voidCalled when the runtime should close because of an error.
deleteUnusedRoutes(unusedRoutes)voidAfter GC has run, called to delete objects in the runtime whose routes are unused.
getCurrentReferenceTimestampMs()number | undefinedReturns a referenced timestamp to be used to track unreferenced nodes.
getGCData(fullGC)Promise<IGarbageCollectionData>Returns the garbage collection data of the runtime.
getNodeType(nodePath)GCNodeTypeReturns the type of the GC node.
updateStateBeforeGC()Promise<void>Before GC runs, called to notify the runtime to update any pending GC state.
updateUsedRoutes(usedRoutes, gcTimestamp)voidAfter GC has run, called to notify the runtime of routes that are used in it.

Method Details​

closeFn​

Called when the runtime should close because of an error.

Signature​

closeFn(error?: ICriticalContainerError): void;

Parameters​

ParameterModifiersTypeDescription
erroroptionalICriticalContainerError

deleteUnusedRoutes​

After GC has run, called to delete objects in the runtime whose routes are unused.

Signature​

deleteUnusedRoutes(unusedRoutes: string[]): void;

Parameters​

ParameterTypeDescription
unusedRoutesstring[]

getCurrentReferenceTimestampMs​

Returns a referenced timestamp to be used to track unreferenced nodes.

Signature​

getCurrentReferenceTimestampMs(): number | undefined;

Returns​

Return type: number | undefined

getGCData​

Returns the garbage collection data of the runtime.

Signature​

getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;

Parameters​

ParameterModifiersTypeDescription
fullGCoptionalboolean

Returns​

Return type: Promise<IGarbageCollectionData>

getNodeType​

Returns the type of the GC node.

Signature​

getNodeType(nodePath: string): GCNodeType;

Parameters​

ParameterTypeDescription
nodePathstring

Returns​

Return type: GCNodeType

updateStateBeforeGC​

Before GC runs, called to notify the runtime to update any pending GC state.

Signature​

updateStateBeforeGC(): Promise<void>;

Returns​

Return type: Promise<void>

updateUsedRoutes​

After GC has run, called to notify the runtime of routes that are used in it.

Signature​

updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;

Parameters​

ParameterModifiersTypeDescription
usedRoutesstring[]
gcTimestampoptionalnumber