Reputation: 679
I've read in several places that StreamingMarkupBuilder is better suited to writing large XML documents than MarkupBuilder. However, I've been unable to find a definitive answer as to why that is.
Can someone please explain why StreamingMarkupBuilder performs better for writing large documents than MarkupBuilder?
Upvotes: 2
Views: 1408
Reputation: 445
In my understanding, streamingMarkupBuilder vs. MarkupBuilder is a bit like SAX vs. DOM : the second one loads the full structure of the document in memory, where the first one handles the document as it comes, loading curent position when it's needed, as it is loaded.
An other image may be using iterators vs. using the whole list.
Hope it helps
Upvotes: 1
Reputation: 13859
As i see main difference is in an overhead with Identation. MarkupBuilder makes a lot actions to make prettyPrinted xml string, when streaming writer produces one-line output.
As I think, you can provide your IndentPrinter, and so minimise overhead.
There is a same question here, but it's not too clear answered.
By the name, I should propose, that Streaming will write data directly in stream, and Not-Streaming version - accumulate in-memory document structure. But in the source of StreamingMB and Ordinary MB I can't find a core difference, that could say, that MB is storing unnecessary data.
So, I think, indentation is only bottleneck.
Upvotes: 1