United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6668279 (spec) System.gc() should indicate that we don't recommend use and don't guarantee behaviour
JDK-6668279 : (spec) System.gc() should indicate that we don't recommend use and don't guarantee behaviour

Details
Type:
Enhancement
Submit Date:
2008-02-27
Status:
Open
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
Component:
core-libs
OS:
windows_xp
Sub-Component:
java.lang
CPU:
x86
Priority:
P5
Resolution:
Unresolved
Affected Versions:
6
Targeted Versions:

Related Reports

Sub Tasks

Description
A DESCRIPTION OF THE PROBLEM :
The documentation for System.gc() is extremely misleading and fails to make reference to the recommended practise of _never_ calling System.gc().

The choice of language leaves it unclear what the behaviour would be when System.gc() is called and what external factors will influence the behaviour.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Calling the gc method asks the Java Virtual Machine to 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 may have made a best effort to reclaim space from all discarded objects.

The documentation should state that use of this method is not recommended and should provide a reference to the GC FAQ http://java.sun.com/docs/hotspot/gc1.4.2/faq.html and the GC tuning guide http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html

The documentation should make reference to the fact that it's possible to prevent the gc() method from doing anything by using certain jvm configurations.
ACTUAL -
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.

URL OF FAULTY DOCUMENTATION :
http://java.sun.com/javase/6/docs/api/java/lang/System.html#gc()

                                    

Comments



Hardware and Software, Engineered to Work Together