[fpc-pascal] How to save a huge XML?

Michael Van Canneyt michael at freepascal.org
Tue Jun 18 16:01:30 CEST 2013



On Tue, 18 Jun 2013, Marcos Douglas wrote:

> On Tue, Jun 18, 2013 at 10:44 AM, Michael Van Canneyt
> <michael at freepascal.org> wrote:
>>
>>
>> On Tue, 18 Jun 2013, Marcos Douglas wrote:
>>
>>>> No. The writer already uses a fixed buffer. Your problem is the use of
>>>> TXMLDocument.
>>>
>>>
>>> Ideas? Maybe do what Antonio Fortuny said before?
>>>
>>>>
>>>> Simply put: logging to XML (worse: using DOM) is a VERY bad idea.
>>>
>>>
>>> Well, this is a request of my client. Other process will read this XML.
>>
>>
>> Under no circumstances should you use TXMLDocument for this.
>
> So, where is recommended to use TXMLDocument class?

General XML processing. Small documents.

You should be aware that the DOM always has the whole XML document in memory, 
plus a substantial amount of overhead. This is not something FPC specific, but is 
inherent in the DOM model. (a W3 spec)

Regardles of XML or not: keeping logs in memory is simply a bad idea. 
You can buffer them for performance reasons, but after some time you must write to file.

The DOM model does not allow this.

Michael.



More information about the fpc-pascal mailing list