8220238: Enhancing j.l.Runtime/System::gc specification with an explicit 'no guarantee' statement

Reviewed-by: shade, dholmes, mchung, plevart
This commit is contained in:
Roger Riggs 2019-06-05 10:21:02 -04:00
parent 9e80843829
commit ab88704c67
2 changed files with 24 additions and 16 deletions
src/java.base/share/classes/java/lang

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -639,15 +639,20 @@ public class Runtime {
public native long maxMemory(); public native long maxMemory();
/** /**
* Runs the garbage collector. * Runs the garbage collector in the Java Virtual Machine.
* Calling this method suggests that the Java virtual machine expend * <p>
* effort toward recycling unused objects in order to make the memory * Calling this method suggests that the Java Virtual Machine
* they currently occupy available for quick reuse. When control * expend effort toward recycling unused objects in order to
* returns from the method call, the virtual machine has made * make the memory they currently occupy available for reuse
* its best effort to recycle all discarded objects. * by the Java Virtual Machine.
* When control returns from the method call, the Java Virtual Machine
* has made a best effort to reclaim space from all unused objects.
* There is no guarantee that this effort will recycle any particular
* number of unused objects, reclaim any particular amount of space, or
* complete at any particular time, if at all, before the method returns or ever.
* <p> * <p>
* The name {@code gc} stands for "garbage * The name {@code gc} stands for "garbage
* collector". The virtual machine performs this recycling * collector". The Java Virtual Machine performs this recycling
* process automatically as needed, in a separate thread, even if the * process automatically as needed, in a separate thread, even if the
* {@code gc} method is not invoked explicitly. * {@code gc} method is not invoked explicitly.
* <p> * <p>

@ -1782,14 +1782,17 @@ public final class System {
} }
/** /**
* Runs the garbage collector. * Runs the garbage collector in the Java Virtual Machine.
* * <p>
* Calling the {@code gc} method suggests that the Java Virtual * Calling the {@code gc} method suggests that the Java Virtual Machine
* Machine expend effort toward recycling unused objects in order to * expend effort toward recycling unused objects in order to
* make the memory they currently occupy available for quick reuse. * make the memory they currently occupy available for reuse
* When control returns from the method call, the Java Virtual * by the Java Virtual Machine.
* Machine has made a best effort to reclaim space from all discarded * When control returns from the method call, the Java Virtual Machine
* objects. * has made a best effort to reclaim space from all unused objects.
* There is no guarantee that this effort will recycle any particular
* number of unused objects, reclaim any particular amount of space, or
* complete at any particular time, if at all, before the method returns or ever.
* <p> * <p>
* The call {@code System.gc()} is effectively equivalent to the * The call {@code System.gc()} is effectively equivalent to the
* call: * call: