xml-xalan-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernard D'Have" <bdhave....@tiscali.be>
Subject RE: Xalan memoryleak when transformation runs in an own thread
Date Thu, 03 Feb 2005 21:06:05 GMT
Hi Daniel,

I think that I have a workaround.
We don't have any memory leak on our server but we use a SaxSource as
Source, constructed with a XmlReader like this

new SAXSource(new org.apache.xerces.parsers.SAXParser(),
org.xml.sax.InputSource);

We use a Source like that for the input document as well for the stylesheet.

You can also use a pool of xmlreader (we use poolman) to reuse SAXParser.
<Bernard/>


-----Original Message-----
From: Daniel Pfeifer [mailto:Daniel.Pfeifer@tradedoubler.com] 
Sent: Wednesday, February 02, 2005 9:16 AM
To: xalan-dev@xml.apache.org
Subject: RE: Xalan memoryleak when transformation runs in an own thread


Well, the bug ID is XALANJ-2052. Do you have any workarounds for the time
being? Since the memory leak is so severe we can not continue working with
Xalan unless we know a way how to quickly fix this, we simply can't restart
the server every couple of hours considering we have a 99.9x% SLA.

/Daniel

-----Original Message-----
From: John Gentilin [mailto:gentijo@eyecatching.com] 
Sent: den 2 februari 2005 00:58
To: xalan-dev@xml.apache.org
Subject: Re: Xalan memoryleak when transformation runs in an own thread

Daniel,

Can you log on to JIRA and submit a but request.
http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10584

Thank you
John G

Daniel Pfeifer wrote:

>Dear Sirs,
>
>We are currently using Xalan in a live environment with high
performance
>requirements. Ever since we started using Xalan we have been 
>experiencing a problem during transformation. After our server has been 
>serving a couple of million requests it keeps consuming more and more 
>memory until the virtual machines responds with an OutOfMemoryError. We 
>have been profiling the application and came to the conclusion that the 
>Xalan is leaking memory when TransformerImpl.transform() is executed in 
>its own thread (it's started in an own thread so we can wait for the 
>thread to die for like 5 seconds and if the thread is not finished yet, 
>we will get back to the thread at some later time and check again).
>
>However, the Profiler (there is a Profiler capture available if someone 
>needs it) pointed out following classes as consuming huge amounts of
>memory:
>
>org.apache.xerces.parser.SAXParser
>org.apache.xml.utils.XMLReaderManager
>org.apache.xalan.xsltc.dom.SAXImpl
>
>According to the profiler the XMLReaderManager holds a class-variable 
>called m_inUse of type Hashtable. This table seems to increase for
every
>new transformation. It never ever decreases, and that even though every 
>single thread in which transformer.transform(a,b) executes has been 
>finishing normally.
>
>Since we are under pressure to find a solution to this problem I've
been
>wondering if one knows a workarounfor this problem.
>
>=== TransformerTest.java =====================================
>
>    public String doTransformation(String xml, String xsl) {
>
>	  // ... Code to create the TransformerFactory ...
>
>        Templates t = transformerFactory.newTemplates(new
>StreamSource(new StringReader(xsl)));
>
>        final Transformer transformer = t.newTransformer();
>        StringWriter stringWriter = new StringWriter();
>        final TransformerError transformerError = new 
>TransformerError();
>
>        final Source xmlSource = new StreamSource(new 
>StringReader(xml));
>        final Result transformerResult = new
StreamResult(stringWriter);
>
>        Thread transformerThread = new Thread() {
>            public void run() {
>                try {
>                    transformer.transform(xmlSource,
transformerResult);
>                } catch (Exception e) {
>                    transformerError.setException(e);
>                }
>            }
>        };
>
>        transformerThread.start(); // Start the Transformer thread.
>
>        try {
>            transformerThread.join(5000); // Wait for some seconds, 
>hopefully thread is done after this.
>            if (transformerThread.isAlive()) {
>			// outside the scope of this example
>            }
>        } catch (InterruptedException e) {
>		// outside the scope of this example
>        }
>
>        if (transformerError.getException() != null) {
>            throw transformerError.getException();
>        }
>
>        String xsl = stringWriter.toString();
>        return xsl;
>    }
>
>    private class TransformerError {
>        private Exception exception;
>
>        public Exception getException() {
>            return exception;
>        }
>
>        public void setException(Exception exception) {
>            this.exception = exception;
>        }
>    }
>
>=== TransformerTest.java ============================ END ====
>
>Additionally I would like to add that I did try to use SAXSource, run 
>entire Xalan-related code in the Thread and a couple of other things.
It
>will always leak memory unless I don't use a Thread, which I believe is 
>not an option for me since it does have a purpose.
>
>Don't hesitate to ask additional questions, any tips are helpful.
>
>Thanks in advance,
>Daniel Pfeifer
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xalan-dev-help@xml.apache.org
>
>  
>


-- 
--------------------------------------
John Gentilin
Eye Catching Solutions Inc.
18314 Carlwyn Drive
Castro Valley CA 94546

    Contact Info
gentijo@eyecatching.com
Ca Office 1-510-881-4821
NJ Office 1-732-422-4917



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


Mime
View raw message