JDK-6361860 : Xalan : Exception in thread "Thread-320" java.lang.OutOfMemoryError: Java heap space
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.transform
  • Affected Version: 5.0u6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2005-12-12
  • Updated: 2012-04-25
  • Resolved: 2007-03-14
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
5.0u12Resolved
Related Reports
Duplicate :  
Description
This sample piece of code will trigger OOM on jdk1.5.0_06. 

[Full GC 13695K->13669K(14784K), 0.1407826 secs]
ERROR:  'Java heap space'
FATAL ERROR:  'Could not compile stylesheet'
[Full GC 13694K->13694K(14784K), 0.1335922 secs]
[Full GC 13694K->13598K(14784K), 0.1605842 secs]
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:619)
        at test$1.run(test.java:33)


Same issue with 1.5.0_07
bash-2.05# /net/koori.sfbay/onestop/jdk/1.5.0_07/promoted/latest/binaries/solaris-sparc/bin/java -verbose:gc -Xmx16m test 


ERROR:  'Java heap space'
FATAL ERROR:  'Could not compile stylesheet'
[Full GC 12784K->12637K(14592K), 0.1542826 secs]
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:619)
        at test$1.run(test.java:33)



It is working fine on jdk 1.4.2_10 and jdk 1.6_b63
----------------------------------------------------------------------------------------
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class test {

 public static void main (String[] args) throws Exception, TransformerFactoryConfigurationError
    {
        final TransformerFactory newInstance = TransformerFactory.newInstance();
//        final   ChannelCache cache;
        final Object monitor = new Object ();
 //         cache = ChannelCache.instance();

        for (;;)
        {
            synchronized (monitor)
            {

new Thread ()
{
public void run ()
{

try
{
synchronized (monitor)
{
Source xsl = new StreamSource ("test.xsl");
Transformer transformer = newInstance.newTransformer(xsl);
Source xml = new StreamSource ("test.xml");
transformer.transform(xml, new StreamResult ("ouput.xml"));
//cache.addCachedContent("123");
monitor.notify();
}
}
catch (Exception e)
{
e.printStackTrace();

}
}
}.start();
monitor.wait();

Thread.yield();
            }

        }
 }
--------------------------------------------------------------------------------


------------------------test.xsl

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:template match="foo">
   <out><xsl:value-of select="."/></out>
 </xsl:template>
</xsl:stylesheet>

------------------------ test.xml

<?xml version="1.0"?>
<foo>Hello XSL 348298409328409328409328409328409328409328409328409328403298409328409328409328403298403298403298403298403298403928403
284032840329840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000</foo>

----------------------------------------

Comments
EVALUATION To respond to ashokM's comments: This patch had been integrated into JDK5 since update 12. It's possible that you could have hit a different issue. Could you contact support with a testcase that shows the issue you're having? Thanks.
18-06-2008

EVALUATION this is valid XML + XSLT and should not cause an out of memory error. bug is being accepted.
13-12-2005