title: DomPDF render of large HTML file results in 500 error
body: <p>I'm using the most recent version of DomPDF (0.6.0 beta 3). </p>
  
  <p>PHP Version is 5.2.17. </p>
  
  <p>Unfortunately, I'm on a shared hosting account and upgrading PHP and similar actions are unavailable. I also don't have access to the apache error logs, which I don't think would be very helpful anyways. </p>
  
  <p>I've set the <code>memory_limit</code> of PHP to <code>2048M</code> and the <code>max_execution_time</code> to <code>999</code>. Although I don't know if they've taken effect. I think they actually don't matter because I feel like DomPDF isn't timing out or running out of memory. The 500 error seems to occur just 10 seconds after requesting the page, when I attempt to generate a PDF with fewer pages the script takes longer (12-15 seconds) but ends successfully. </p>
  
  <p>I have an HTML file that's 72.3kb large, with only one small HTML table. (In fact, removing the page with the table does nothing to help the problem.) The PDF should result in about 35 pages. </p>
  
  <p>After lots and lots of digging I found the error occurs on the 30th - 31st page, on the following line of code in <code>page_frame_reflower.cls.php</code> inside the <code>reflow</code> function:</p>
  
  <pre><code>  // Render the page
    $this-&gt;_frame-&gt;get_renderer()-&gt;render($child);
  </code></pre>
  
  <p>When <code>echo</code>ing <code>memory_get_usage</code> on each loop(page) the value stays pretty consistent, under 5% of available memory, it seems. </p>
  
  <p>Using <code>get_class</code> on <code>$this-&gt;_frame-&gt;get_renderer()</code> I was able to determine that the problem function is <code>Renderer::render()</code>. </p>
  
  <p>Unfortunately, there's no easy way for me to continue debugging with my current methods. The method <code>Renderer::render()</code> won't let me add the counter variable to the parameters because it needs to be compatible with it's parents function. </p>
  
  <p>Anybody got any help for me, do you see anything I'm missing - can you point me in the right direction to fixing these 500 errors?</p>
  
  <p><strong>Edit:</strong> I've removed all uses of inline PHP from the HTML document, and it didn't seem to change anything. </p>
  
  <p><strong>Edit 2:</strong> The document was too large to completely run through Tidy, but up to 50000 bytes had no errors. </p>
  
  <p><strong>Edit 3:</strong> PHP Error logging has been turned on. I can generate errors by calling wrong method names and other things. Those errors appear on the screen. In fact, even when I cause an infinite loop before the problem method, I get PHP maximum execution time reached errors printed to the screen. However the problem area shows a 500 Internal Server Error page. </p>
  
  <p><strong>Edit 4:</strong> I stripped out all of my CSS and the PDF was generated without styling. Now we're getting somewhere. I'll slowly add the CSS back in and I can narrow down what the problem code. Thanks, @Liv.</p>
  
  <p><strong>Edit 5:</strong> I narrowed down the CSS to the bud of the problem: the h1 rule. I was using a background image on the h1 tags. So from my original problem, all I had to do was remove the background images from the h1 tag to get the PDF to work properly. Is handling a lot of elements with background images a problem for DomPDF?</p>
  
  <p><strong>Edit 6:</strong> Here's the HTML file: <a href="http://www.pickering-mcaloon.com/wp-content/uploads/2013/03/test2.html" rel="nofollow">http://www.pickering-mcaloon.com/wp-content/uploads/2013/03/test2.html</a> I had to strip out the content (wasn't mine). I tested this version of the HTML with DomPDF and got a 500 server error. My header image is 25.1 kb. It should be noted that the footer of every page also uses a background image and it works fine. In this copy of the HTML, removing 1 "Chapter" section permitted DomPDF to finish the generating the PDF. </p>
  
  <p><strong>Edit 7:</strong> When I first ran into the problem I had used <code>memory_get_usage</code> and at the top of the loop where <code>Renderer::render()</code> is called, each time it showed a slightly different usage, but under 6% of the max, which was set to <code>2048M</code>. I don't believe this problem is a timeout error or a memory error, because I can produce these types of errors before the call to <code>render</code> and get the PHP errors printed to the screen. Also, the 500 error appears after about 10 seconds of runtime - When the PDF works it takes about 15-20 seconds. So a timeout is unlikely. Memory errors, perhaps but if so why not print the error as it does if the memory overflows before the call to <code>render</code>. </p>
  
  <p><strong>Edit 8:</strong> I converted the image I was using as a background image for the h1 tags to a JPG from a PNG, which reduced its size from 25.1kb to 2.6kb and the PDF generated properly. This is likely a memory issue. PHP should generate an error and show it to me, but it doesn't. </p>