Share via


Runtime.Gc Method

Definition

Runs the garbage collector.

[Android.Runtime.Register("gc", "()V", "GetGcHandler")]
public virtual void Gc ();
[<Android.Runtime.Register("gc", "()V", "GetGcHandler")>]
abstract member Gc : unit -> unit
override this.Gc : unit -> unit
Attributes

Remarks

Runs the garbage collector. Calling this method suggests that the Java virtual machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the virtual machine has made its best effort to recycle all discarded objects.

The name gc stands for "garbage collector". The virtual machine performs this recycling process automatically as needed, in a separate thread, even if the gc method is not invoked explicitly.

The method System#gc() is the conventional and convenient means of invoking this method.

Java documentation for java.lang.Runtime.gc().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to