How to Improve Performance
Consider the following things:
- The static helper methods in the JAXB class (JAXB.marshal and JAXB.unmarshall) should be avoided if you need to invoke them repeatedly. Instead, create a JAXBContext instance once and work with the Marshaller and Unmarshaller interfaces.
- Make sure you have only a single JAXBContext instance and share it across objects and threads.
- Don't use schema validation (if possible).
- Check that you use the best source or destination for the serialization/deserialization process. For example, if you want to transmit XML over the net, write it directly into the connection's OutputStream. Try to avoid temporary storage of the XML using ByteArray streams or in DOM trees.
- If the document contains binary data, use a XOP transport if possible.
- If you are sure you can't reach your performance target using JAXB, switch to the XMLStreamReader/XMLStreamWriter interfaces (StAX API) for those parts that are too slow. Note that using this low-level API can be a lot more work than using JAXB, and getting the code to work right in all possible situations (e.g. comments in the middle of an XML text) is even more difficult.

