Skip to content
This repository was archived by the owner on Jan 2, 2019. It is now read-only.

Excel2007 disk cache #353

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

Excel2007 disk cache #353

wants to merge 8 commits into from

Conversation

nud
Copy link

@nud nud commented Apr 16, 2014

These commits reduce the memory usage due to disk caching in the Excel2007 writer by ensuring that:

  • the XMLWriter flushes regularly to the disk;
  • temporary files are not read wholly into the RAM to be written again when it can be avoided.

The PCLZip compatibility is lame and can probably be enhanced...

nud added 8 commits April 14, 2014 16:08
The PHP XMLWriter class doesn't automatically flush out the generated
XML document into the associated files. As the code doesn't explicitely
call the "flush()" method anywhere, it means the document is only
flushed once, when closing the document.

To make disk caching effective in reducing memory usage, this commit
overrides some methods of XMLWriter in order to trigger an automatic
flush every 100 XML elements, in order to keep the memory used by the
XMLWriter as low as possible.
The purpose is to track the generated file names and "garbage collect"
them at once.
…mory.

The potential gain in memory usage offered by disk caching was
annihilated by the fact that the generated content was read into memory
before being added to the archive.
When we have a file name for the image being added to the ZIP file,
there is no need to read it into memory.
This reduces code duplication among the various parts.
XMLWriter now takes the temporary file name as an argument, allowing us
to make a better management of the temporary files though the tracker
object. This allows us to manage the lifetime of the various temporary
files more easily.
@Gemorroj
Copy link
Contributor

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants