Closed fefe982 closed 10 years ago
Took a look at the code related to exporting. When exporting to XML, the whole DOM structure and the whole generated XML string (and maybe many other stuff) are kept in memory at the same time. This should have cause the out of memory problem with my big book, whose GNC XML file (unzipped) generated by GnuCash is 12M.
This may need a change of the export interface to change. The current interface returns the exported content as a String
. We can let the interface take a Writer
(or something alike) as a parameter and write to it. If we want a String
, then we can pass in a StringWriter
. If we are exporting to file, a FileWriter
can be used to reduce memory cost.
Also, although using DOM to export XML is very intuitive, we do not have to generate the DOM at all when exporting to XML. We can take the database content and write the XML directly. Android has org.xmlpull.v1.XmlSerializer
(API level I) to do the job. See http://stackoverflow.com/a/2296051/1058916 and http://stackoverflow.com/a/5186414/1058916 .
The GncXmlExporter
does not seem to check or set the exported status, is it right?
I concur. This was an artifact of the former support for exporting only changed transactions. The export files tended to be small. But the XML export backs up everything which can be a bit heavy. I will change the interface to work accordingly. Or do you want to do it?
On 02.09.2014, at 16:19, Yongxin Wang notifications@github.com wrote:
Took a look at the code related to exporting. When exporting to XML, the whole DOM structure and the whole generated XML string (and maybe many other stuff) are kept in memory at the same time. This should have cause the out of memory problem with my big book, whose GNC XML file (unzipped) generated by GnuCash is 12M.
This may need a change of the export interface to change. The current interface returns the exported content as a String. We can let the interface take a Writer (or something alike) as a parameter and write to it. If we want a String, then we can pass in a StringWriter. If we are exporting to file, a FileWriter can be used to reduce memory cost.
Also, although using DOM to export XML is very intuitive, we do not have to generate the DOM at all when exporting to XML. We can take the database content and write the XML directly. Android has org.xmlpull.v1.XmlSerializer (API level I) to do the job. See http://stackoverflow.com/a/2296051/1058916 and http://stackoverflow.com/a/5186414/1058916 .
— Reply to this email directly or view it on GitHub.
No it doesn't. XML exports are always the whole file.
On 02.09.2014, at 16:43, Yongxin Wang notifications@github.com wrote:
The GncXmlExporter does not seem to check or set the exported status, is it right?
— Reply to this email directly or view it on GitHub.
Changing the interface would affect a lot of things. I can do the XML part, and I know something about QIF. But I never touched the OFX format.
The DB access strategy should also change to make the exporting of the whole book faster, one query for Accounts and one query for Transactions should be enough.
I think I would do the XML part first, add separate function in the XML exporter, using XMLSerializer and a new db access strategy and may be write directly to a zipped file (when this is a backup), and see how it works. I won't touch QIF or OFX export or change the abstract interface function until this is finished.
See #193 for new XML export, #198 for QIF export.
I didn't find enough documents on OFX format to do a full rewrite for OFX export. Changing only the interface is easy, as a StringWriter
is used inside OFXExporter.generateExport
, just replace it with the argument writer
would be enough. However, to get a faster exporter a full rewrite would be needed, which requires knowledge about the OFX format.
I'll leave OFX export there and try what I can do with the problems introduced by #188 . Will create a new issue to discuss the details. Are you already working on this?
Yes, I think we can leave OFX as-is. It doesn't support double entry transactions anyway and is a hassle to use to import transactions into the desktop GnuCash.
So this can be closed now right?
Sure, I'll close it.
Again with my large book, when I tried to delete all the transactions, the backup procedure triggered an out-of-memory exception. The stack trace is as follows: