Out of memory error processing data
pascalchevrel opened this issue · comments
Hi,
For even moderate html content, like 10Kb, I get a memory error:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 131599 bytes) in /home/pascalc/repos/github/transvision/vendor/gajus/dindent/src/Parser.php on line 70
Please include example HTML and phpinfo dump.
On Apr 1, 2014, at 18:54, Pascal Chevrel notifications@github.com wrote:
Hi,
For even moderate html content, like 10Kb, I get a memory error:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 131599 bytes) in /home/pascalc/repos/github/transvision/vendor/gajus/dindent/src/Parser.php on line 70
—
Reply to this email directly or view it on GitHub.
Not enough information provided to trace the bug/issue. Possible env setting issue.
Hi there @gajus, I've been using dindent for a couple weeks on a new small project and worked pretty well so far. Now I'm getting the same memory issue the OP mentioned.
The error points line 142:
$output .= str_repeat($this->options['indentation_character'], $indentation_level) . $matches[0] . "\n";
I'm using it this way, inside a template generator function:
public function render(){
ob_start();
$this->beginHtml();
$this->getHead();
$this->beginBody();
$this->getHeader();
$this->getContents();
$this->getFooter();
$this->getJs();
$this->endBody();
$this->endHtml();
#render without indenter
#echo ob_get_clean();
#render with indenter
echo $this->indenter->indent(ob_get_clean());
}
I got rid from the error by echo-ing the ob_get_clean()
directly (which is commented in the code above), but I lost of course the beautiful indentation. Any input will be very appreciated. Thanks!