Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:59:06+00:00 2026-06-12T08:59:06+00:00

Consider that I have an XML Document loaded as a byte[] that is 5MB

  • 0

Consider that I have an XML Document loaded as a byte[] that is 5MB in size. Being a byte array, it takes up exactly 5MB of memory. I have a stylesheet Source that I want to apply to this document and perform something like the below.

final TransformerFactory transformerFactory = TransformerFactory.newInstance();
final Transformer transformer = transformerFactory.newTransformer(styleSheet);

transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

final StringWriter writer = new StringWriter();

transformer.transform(convertStringToSource(filePayload), new StreamResult(writer));

return writer.getBuffer().toString().getBytes();

When run on the server (WebSphere App Server 7 – with limits on contiguous memory allocation) I get heap dumps that indicate objects of 10 – 15 MB are created. I presume the transform() method will create an object internally, store the original xml as an object, the stylesheet as an object, and the result as an object. Add those together and I’m at a minimum of 2*input+stylesheet MB. Is there a more efficient way to do this, that keeps my footprint to a minimum?

You might say – it’s only 10MB, but in my case, performance is critical. The time it takes to allocate that much contiguous memory adds up when I have to transform hundreds or thousands of documents at a time. Thus our server admins have this limit set as a warning of sorts that more memory is being allocated than recommended.

FYI, the following JVM parameter sets this in WebSphere: -Xdump:stack:events=allocation,filter=#5m​.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:59:07+00:00Added an answer on June 12, 2026 at 8:59 am

    A factor of 3 expansion between the raw XML size and the size of the in-memory tree is certainly normal; in fact it’s low. See for example http://dev.saxonica.com/blog/mike/2012/09/

    Streamed transformation is starting to become possible for a limited class of transformations. See for example http://www.saxonica.com/documentation/sourcedocs/streaming.xml. But when your documents are only 5Mb in size, I’m not sure it’s the right approach for you, at least not without further evidence.

    It seems to me that you have come to the conclusion that memory allocation by the XSLT processor is the critical factor affecting the performance of your workload without any real evidence that this is the case. It would be interesting to see, for example, what the transformation time is in relation to the parsing time – many people are surprised that sometimes the transformation cost is tiny compared to the parsing cost. Before addressing one aspect of your system performance, you need to work out what the true bottlenecks are.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that we have multiple arrays of integers. You can consider each array as
I want to parse text from a xml file.Consider that I have a some
Consider that we have a DIV with fixed height. Without a defined width ,
Consider that I have 1 resource and 2 urls (let's say new one and
I have a chat application(Socket Programming) , for that consider I have 2 separate
Consider the apps that large blogs have (which work pretty much like an RSS
I have a configuration file that I consider to be my base configuration. I'd
Let's consider we have QWidget that contains QTableWidget (only). So we want to resize
Consider following scenario: I have RESTful URL /articles that returns list of articles user
Consider the following scenario We have a simple database that involves two entities: user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.