Monitor memory usage with each file processed by FileLoader::executeActions()

Abort early if usage might exceed the PHP memory limit.  Resolves pkp/pkp-lib#245.
I think that PHP will not copy the entire object, it will just use
reference. See here:
http://php.net/manual/en/features.gc.refcounting-basics.php

2014-12-09 19:19 GMT-02:00 Clinton Graham <notifications@github.com>:

> In classes/task/FileLoader.inc.php
> <https://github.com/pkp/pkp-lib/pull/250#discussion-diff-21563133>:
>
> >  		while($filePath = $this->_claimNextFile()) {
> > +			// We'll have a substantial memory bump when converting the execution log to a string at the end of this process
> > +			// Keep track of the largest known log increase to preempt out-of-memory errors
> > +			$newLogSize = strlen(serialize($this->_executionLog));
>
> I see the benefit of the generalization, but I wonder if it is worth the
> effort without an exception framework.
>
> Incidentally, I think I've found the bigger problem. I don't think the
> memory issue is so much
> https://github.com/pkp/pkp-lib/blob/ojs-dev-2_4/classes/scheduledTask/ScheduledTask.inc.php#L147
> as it is
> https://github.com/pkp/pkp-lib/blob/ojs-dev-2_4/classes/scheduledTask/ScheduledTask.inc.php#L146.
> I think this line makes a copy of the full executionLog array, which is
> substantially larger than the serialized string version. There's a LOT of
> array overhead:
> http://nikic.github.io/2011/12/12/How-big-are-PHP-arrays-really-Hint-BIG.html
>
> I'm testing $logString = implode(PHP_EOL . PHP_EOL, $this->_executionLog);
> there.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/pkp/pkp-lib/pull/250/files#r21563133>.
>