I have a service implementation that returns an OMElement. My typical results returned are rather large xml payloads, therefore I am trying to optimize my memory usage on the server-side. In my service impl, I am getting the resulting xml payload as a ByteArrayInputStream, and using the StAXOMBuilder to then construct the OMElement for me, to be returned. Another point of memory optimization is to not have the StAXOMBuilder build the complete OMElement in memory, saving myself some significant memory on large xml results. So I am doing something like this:
// bais is the ByteArrayInputStream containing the xml result StAXOMBuilder builder = new StAXOMBuilder(bais); // Turn off caching to save some memory builder.setCache(false); OMElement response = builder.getDocumentElement(); The problem is that this code will completely hang the server on the builder.getDocumentElement() line. If I change the line above that to builder.setCache(true), which is also the default, then it does not hang, but I see significant memory used by the full creation of the OMElement container. My question is, shouldn't the setCache(false) not hang the server? Additionally, is there a better way for me to achieve the same results of not incurring a memory hit of a full OMElement creation? Thanks in advance for any help. Wes
