JDK-4035345 : String.intern() fails after about 100,000 calls
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.0,1.1,1.1.1,1.1.3
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS:
    solaris_2.5,solaris_2.5.1,windows_nt solaris_2.5,solaris_2.5.1,windows_nt
  • CPU: x86,sparc
  • Submitted: 1997-02-28
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2betaFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description

Name: mc57594			Date: 02/27/97


for (int ndx = 0; ndx < 100000; ndx++) {
          String.valueOf(ndx).intern();
      }
company - Mentor Graphics Corp. , email - ###@###.###
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2beta INTEGRATED IN: 1.2beta
14-06-2004

WORK AROUND Name: mc57594 Date: 02/27/97 ======================================================================
11-06-2004

PUBLIC COMMENTS If you <code>String.intern()</code> more than 32K (2^15) strings, AND both these conditions are true: <ul> <li> they are all unique strings, i.e., for any two <code>s1</code> and <code>s2</code> from these 32K strings, <code>(s1.equals(s2) == false)</code> <li> all these strings return the same hash value with the runtime hashing algorithm (NOT the one returned by <code>String.hashCode()</code>) </ul> then (1) you may get a spurious <code>OutOfMemoryError</code> and (2) you cannot rely on <code>String.intern()</code> behaving correctly thereafter. <p> This does NOT mean that the upperbound on the number of strings you can intern with <code>String.intern()</code> is 32K. In fact it is much higher, depending on whether the strings produce sufficiently random hash values. <p> This limitation also applies to method and field names/signatures, which are hashed with the same algorithm. <p> In practice it should be rare to encounter this bug. This bug will NOT crash the Java Virtual Machine. There are no known workarounds.
10-06-2004

EVALUATION Sheng now has a fix for this in 1.2beta. We finally garbage collect interned strings! anand.palaniswamy@Eng 1997-09-10
10-09-1997