%% %CopyrightBegin%
%%
%% SPDX-License-Identifier: Apache-2.0
%%
%% Copyright Ericsson AB 2021-2025. All Rights Reserved.
%%
%% %CopyrightEnd%

[;1m  garbage_collect(Pid, OptionList)[0m

[;;4mSince[0m:
  OTP 17.0

  Garbage collects the node local process identified by [;;4mPid[0m.

  [;;4mOption[0m:

   • [;;4m{async, RequestId}[0m - The function [;;4mgarbage_collect/2[0m
     returns the value [;;4masync[0m immediately after the request has
     been sent. When the request has been processed, the process
     that called this function is passed a message on the form [;;4m[0m
     [;;4m{garbage_collect, RequestId, GCResult}[0m.

   • [;;4m{type, 'major' | 'minor'}[0m - Triggers garbage collection of
     requested type. Default value is [;;4m'major'[0m, which would
     trigger a fullsweep GC. The option [;;4m'minor'[0m is considered a
     hint and may lead to either minor or major GC run.

  If [;;4mPid[0m equals [;;4mself/0[0m, and no [;;4masync[0m option has been passed,
  the garbage collection is performed at once, that is, the same as
  calling [;;4mgarbage_collect/0[0m. Otherwise a request for garbage
  collection is sent to the process identified by [;;4mPid[0m, and will be
  handled when appropriate. If no [;;4masync[0m option has been passed,
  the caller blocks until [;;4mGCResult[0m is available and can be
  returned.

  [;;4mGCResult[0m informs about the result of the garbage collection
  request as follows:

   • [;;4mtrue[0m - The process identified by [;;4mPid[0m has been garbage
     collected.

   • [;;4mfalse[0m - No garbage collection was performed, as the process
     identified by [;;4mPid[0m terminated before the request could be
     satisfied.

  Notice that the same caveats apply as for [;;4mgarbage_collect/0[0m.

  Failures:

   • [;;4mbadarg[0m - If [;;4mPid[0m is not a node local process identifier.

   • [;;4mbadarg[0m - If [;;4mOptionList[0m is an invalid list of options.
