You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a large XML document (ca. 1.9GB on disk).
Using XMLDocument::Print to write this document to a file always causes a std::bad_alloc to be thrown:
namespacexml= tinyxml2;
voidtoStream( const xml::XMLDocument* doc, std::ostream& os ){
xml::XMLPrinter streamer;
doc->Print( &streamer );
os << streamer.CStr();
}
The exception was thrown before XMLDocument::Print returned.
On the other hand, using XMLDocument::SaveFile did not throw:
namespacexml= tinyxml2;
namespacefs= std::filesystem;
voidtoFile( xml::XMLDocument* doc, const fs::path& filePath ){
xml::XMLError ret { doc->SaveFile( filePath.c_str() ) };
if ( ret != xml::XML_SUCCESS ){
// error handling here
}
}
Maybe it would make sense to unify these functions.
The text was updated successfully, but these errors were encountered:
Out of curiosity are you compiling for x86, i.e. 32-bit, targets? It's my understanding that processes run in 32-bit mode are only allowed 2 GB of memory. 1.9 GB is really close to that limit and if you were to have a lot of heap allocated memory elsewhere you can easily go over that limit and the program can't allocate any more.
Since XMLPrinter works entirely in-memory it would need to take up 1.9 GB of memory. Hence, the bad_alloc throw.
I have a large XML document (ca. 1.9GB on disk).
Using
XMLDocument::Print
to write this document to a file always causes astd::bad_alloc
to be thrown:The exception was thrown before
XMLDocument::Print
returned.On the other hand, using
XMLDocument::SaveFile
did not throw:Maybe it would make sense to unify these functions.
The text was updated successfully, but these errors were encountered: