Rafał
Rafał

Reputation: 13

PHP Allowed memory size of X bytes exhausted

I'm using mPDF library to create and download PDF files, for example x1000 (singly using ajax) in loop.
Sometimes I get error message for series of files "Allowed memory size of 268435456 bytes exhausted (tried to allocate 261900 bytes)". I read that I have to set bigger memory_limit in configuration but I can't do this, because 256M is my limit.

Is there any other solution for this error?

Upvotes: 0

Views: 948

Answers (2)

Rob W
Rob W

Reputation: 9142

You can reduce memory usage two other ways without increasing the memory limit...

  1. Consider setting $mpdf->simpleTables = true; if you do not need complex table borders, or $mpdf->packTableData = true; if you do not mind the extra processing time.
  2. packTableData – Use binary packing of table data to reduce memory usage

Both of which will increase processing time in order to save memory usage.

Upvotes: 2

David Rojo
David Rojo

Reputation: 2394

Try it in a test environment with higher memory limit, to ensure that the problem is a memory limit issue. Maybe you have an infinite loop or an infinite recursive call that is consuming your memory.

Upvotes: 0

Related Questions