[xsd-users] XSD uses a lot of memory
Maxim Maslennikov
maxim.maslennikov at gmail.com
Thu Mar 12 16:13:07 EDT 2015
Boris,
Enclosed are sources of the program based on libstudxml and xsd file.
The xsd program and xsd file are below:
#include <iostream>
#include <chrono>
#include "test.hxx"
using namespace std;
int main(int argc, const char * argv[]) {
if (argc != 2)
{
cerr << "usage: " << argv[0] << " test.xml" << endl;
return 1;
}
try
{
auto t = chrono::steady_clock::now();
// Parsing and Binding
unique_ptr<test::root> root (test::root_ (argv[1]));
cerr << "Number of elements: " << root->record().size() << endl;
cerr << "Binding Duration: " << chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now()-t).count() << " ms\n”;
// Serialize the modified object model to XML.
//
xml_schema::namespace_infomap map;
map[""].name = "";
map[""].schema = "test.xsd";
t = chrono::steady_clock::now();
test::root_ (cout, *root, map);
cerr << "Serializing Duration: " << chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now()-t).count() << " ms\n";
}
catch (const xml_schema::exception& e)
{
cerr << e << endl;
return 1;
}
}
To test the programs I generated a test file by gen program from libstudxml examples about 100Mb size.
Best Regards,
Maxim
> On Mar 10, 2015, at 3:05 PM, Boris Kolpackov <boris at codesynthesis.com> wrote:
>
> Hi Maxim,
>
> Maxim Maslennikov <maxim.maslennikov at gmail.com> writes:
>
>> I meant my program uses an "object persistance" approach described
>> in your document - "XML Parsing and Serialization in C++ With
>> libstudxml” and also saves all data in memory.
>
> You mean the data for the *entire* document is stored in memory?
>
>
>> So my question is why does xsd C++/tree use about ten time more
>> memory? I found it when generated a file of records about 100Mb
>> size.
>
> If the answer to the above question is "yes", then I will need to
> see a test that reproduces this. C++/Tree definitely shouldn't
> use 10 times more memory.
>
> Boris
More information about the xsd-users
mailing list