Reputation: 545
I started to receive this error in my Laravel log Allowed memory size of 536870912 bytes exhausted (tried to allocate 227371200 bytes)
Is there is any way to get more information on what script / file being attempted to manipulate? I looked for similar size file on server and I couldn't find anything.
My first call was that maybe it's some log file that got too big.
Upping memory limit to 2GB solved the problem partially, but my worry is that this quick fix is not solving actual issue as I have no clue what file is being attempted to change or why script needs so much memory.
From what I can tell it happens when one of my /api function being called.
If it was infinite loop I assume upping the limit would not help.
"class": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
"message": "Allowed memory size of 536870912 bytes exhausted (tried to allocate 227371200 bytes)",
"code": 1,
"file": "\/vendor\/league\/flysystem\/src\/Util\/MimeType.php:188"
}```
Upvotes: 3
Views: 1823
Reputation: 1370
This looks like a known bug in PHP - https://bugs.php.net/bug.php?id=78987 which is caused by an upstream bug in libmagic - https://bugs.astron.com/view.php?id=234
Upvotes: 0
Reputation: 1006
You can handle files as streams to prevent memory issues with large files.
See Storage::putFile()
here or use PHPs fopen()
to get a stream handle you can pass to Laravels storage methods.
Upvotes: 2