Chat on WhatsApp

How do you fix "Allowed memory size exhausted"?

An Allowed memory size of 134217728 bytes exhausted almost always means too much data loaded into memory at once, usually Model::all() on a big table, an unbounded collection, or eager-loading that fans out. We replace it with chunk(), cursor(), or lazy collections, fix any N+1 queries feeding the leak, and only raise memory_limit as a last resort. The fix ships with a test on a representative dataset.

Was this helpful?