Hi everyone, when I transform xml with a xsl-Stylesheet within a seperat thread, which I will start from a Master thread:
and I'm starting the threads from a master thread, which guarantee that only one thread is running in the background:
it will increase the heap utilization until I get an OutOfMemoryError. If I have no xml input for the transformation like:
the heap utilization remains more or less konstant. Of course, if I repeat the xml-transformation with input-xml within one thread the heap utilization keeps konstant too. Do you have any idea? Is it not advisable to start new thread for the transformation of xml, or have I missed something to enable the garbage collector to destroy all content of a thread? I would be very thankful for your help. Regards, Ulrich
I don't understand why you copy the data from the file to an array of bytes in memory, and then parse the array of bytes. That can't be good for your memory usage. Why not just parse directly from the file?
And you may also want to print the stack traces of exceptions that occur, instead of just ignoring them. And close the input and output streams in a finally block, so that even if exceptions do occur, the streams do get closed and can be garbage-collected.
However if you still have memory problems after changing those things, get a profiler and see what class of objects is filling up your memory.
Hi Paul, thanks for your help. You're right, this code is just a simulation of a problem I have at work. There I get the byte-Array from a corba connection. There the code looks like:
But the main problem persists. Why is there a difference of performance between this code and the other, where I don't have any input? Greetings and thanks in advance, Ulrich [ August 23, 2006: Message edited by: Ulrich Heeger ]
I notice that the documentation for TransformerFactory says
An implementation of the TransformerFactory class is NOT guaranteed to be thread safe. It is up to the user application to make sure about the use of the TransformerFactory from more than one thread. Alternatively the application can have one instance of the TransformerFactory per thread. An application can use the same instance of the factory to obtain one or more instances of a Transformer or Templates provided the instance of the factory isn't being used in more than one thread at a time.
It doesn't look like you are synchronizing on the TransformerFactory or anything like that. However I still think you are eventually going to have to use a profiler to find the problem. I think you should start working on that.