I'm generating about 700 PDFs with dompdf and saving them to the disk. Each one involves a database query to fetch the information for the PDF. When I run it I get about 2 minutes in and then it runs out of memory.
Why am I running out of memory? Shouldn't each PDF generation consume x memory, then release it when finished?
What's good practice in PHP for doing large operations like this to avoid strangling your server?
Some more info:
- It generates many PDFs before running out of memory (some 100s)
- The PDF it fails on is not abnormally large or special in any way. They're all between 4KB and ~500KB
- Watching the memory usage as it processes it just slowly climbs in fits and starts until it runs out.
I can't get the wysiwyg to code-format properly, so here's a pastie for the snippets in question: http://pastie.org/3800751