JavaSystem.Gc Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Runs the garbage collector.
[Android.Runtime.Register("gc", "()V", "")]
public static void Gc ();
[<Android.Runtime.Register("gc", "()V", "")>]
static member Gc : unit -> unit
- Attributes
Remarks
Runs the garbage collector.
Calling the gc
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 Java Virtual Machine has made a best effort to reclaim space from all discarded objects.
The call System.gc()
is effectively equivalent to the call: <blockquote>
Runtime.getRuntime().gc()
</blockquote> At API level 34 and lower, this does nothing unless it is preceded or followed by a runFinalization call. Runtime.getRuntime().gc() always attempts to reclaim space.
Calling this indiscriminately is likely to severely degrade performance. Intended primarily for testing.
Java documentation for java.lang.System.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.