faastjs > CommonOptions > gc
Garbage collector mode. Default:
gc?: "auto" | "force" | "off";
Garbage collection deletes resources that were created by previous instantiations of faast that were not cleaned up by FaastModule.cleanup(), either because it was not called or because the process terminated and did not execute this cleanup step. In
"auto" mode, garbage collection may be throttled to run up to once per hour no matter how many faast.js instances are created. In
"force" mode, garbage collection is run without regard to whether another gc has already been performed recently. In
"off" mode, garbage collection is skipped entirely. This can be useful for performance-sensitive tests, or for more control over when gc is performed.
Garbage collection is cloud-specific, but in general garbage collection should not interfere with the behavior or performance of faast cloud functions. When FaastModule.cleanup() runs, it waits for garbage collection to complete. Therefore the cleanup step can in some circumstances take a significant amount of time even after all invocations have returned.
It is generally recommended to leave garbage collection in
"auto" mode, otherwise garbage resources may accumulate over time and you will eventually hit resource limits on your account.
Also see CommonOptions.retentionInDays.