Hello friends.
I have recently begun using xsltc to enhance the performance of transformations.My application involves the following: 1)compiling XSL stylesheets into JVM bytecode using xsltc compiler. 2)using an application class to instantiate the compiled classes and use them to transform my XML documents. I have used some JAVA extensions in my stylesheets using : xmlns:flex="http://xml.apache.org/xslt/java" Following is a code snippet from my extension class: protected static XPathContext ctxt = new XPathContext(); public static int dtmCount = 0; public static int loadDocument(String fileName) throws Exception { BufferedInputStream inputFile = new BufferedInputStream(util.getClass().getResourceAsStream(fileName)); DTM dtm = null; SAXSource source = null; InputSource in = null; in = new InputSource(inputFile); source = new SAXSource(in); dtm = ctxt.getDTM(source,false,null,true,true); dtmArray[dtmCount] = dtm; dtmCount++; return dtmCount-1; } The calls to this method from my XSLs is as follows: <xsl:variable name="xslUtility"> <xsl:value-of select="flex:flex.loadDocument('XSLUtility.xml')" /> </xsl:variable> Thereafter I am trying to use the following snippet to parse my documents: public static String parse(String xpathstr,int docHandle) throws Exception{ dtm = null; dtm =dtmArray[docHandle]; int contextNode = dtm.getDocument(); Node namespaceNode = dtm.getNode(dtm.getDocument()); PrefixResolverDefault prefixResolver = new PrefixResolverDefault( (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? ((Document) namespaceNode).getDocumentElement() : namespaceNode); XPath xpath = new XPath(xpathstr,null, prefixResolver, XPath.SELECT, null); ctxt.popNamespaceContext(); ctxt.pushNamespaceContext(prefixResolver); ctxt.popCurrentNodeAndExpression(); ctxt.pushCurrentNodeAndExpression(contextNode, contextNode); Expression expr = xpath.getExpression(); return(expr.execute(ctxt).str()); } and repeatedly calling the above parse method in my XSLs: <xsl:variable name="strType" select="concat('/XSLUtility/AccountData/account/@*[position() = ',1,']')"/> <xsl:variable name="type"> <xsl:value-of select="flex:flex.parse($strType,number($xslUtility))"></xsl:value-of> </xsl:variable> The problem I am facing is that there is a huge memory leak in my application.I have run the application through a memory profiler and the results all show that a lot of DTM related objects are being formed that the Garbage collector is somehow unwilling to remove.I have a strange feeling that there is something terribly wrong with my code. Please help me!! Kind regards , Subhendu Chatterjee ---------------------------------------------------------------------------- This message contains privileged and confidential information and is intended only for the individual named. If you are not the intended recepient you should not disseminate, distribute, store, print, copy or deliver this message. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and immediately delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. --------------------------------------------------------------------------
