United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6232010 ObjectOutputStream.subclassAudits SoftCache prevents ClassLoader GC
JDK-6232010 : ObjectOutputStream.subclassAudits SoftCache prevents ClassLoader GC

Details
Type:
Bug
Submit Date:
2005-02-23
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2005-09-20
Component:
core-libs
OS:
windows_2000
Sub-Component:
java.io:serialization
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
This problem is similar to that reported in 4405807. When I have a subclass of ObjectOutputStream or ObjectInputStream loaded through a ClassLoader that is later thrown away, the SoftCache in field subclassAudits of both ObjectInputStream and ObjectOutputStream won't let go of the Class object for the stream subclass, and subsequently the ClassLoader that loaded it. The system runs out of memory on few occurrences of reloading the stream subclass through new ClassLoader-s.

In very rare circumstances the class and the class loader will be released, but for this to happen both conditions below must be satisfied:
a) low enough level of free memory so that soft references are cleared
b) but still high enough memory level so that next time code is reloaded and the subclass of ObjectOutputStream initialized, the SoftCache.processQueue() runs without running into OutOfMemoryError first.

A solution to the problem would be to replace the SoftCache with a WeakHashMap. I'd also recommend you revisit the use of the SoftCache across all the JDK code, as together with 4405807, this is at least the second case of it causing trouble.

I just checked, and 1.5.0 source code for ObjectOutputStream still uses SoftCache.


REPRODUCIBILITY :
This bug can be reproduced always.
###@###.### 2005-2-23 05:20:54 GMT

                                    

Comments
EVALUATION

must be fixed in mustang
###@###.### 2005-04-14 19:01:43 GMT
                                     
2005-04-14



Hardware and Software, Engineered to Work Together