• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

transformation of xsl within several threads - performance problems

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 28397
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Paul Clapham
Sheriff
Posts: 28397
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,
thank you for your advice. I've found now the problem: I was using an older version of xalan, after updating my xalan.jar to a newer version, I don't have the problem anymore.
Regards,
Ulrich
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic