Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Michael Fayez's avatar

Allowed memory size of 134217728 bytes exhausted (tried to allocate 41459712 bytes)

what is the solution for this kind of problem- in vendor / spatie / flare-client-php / src / Truncation / ReportTrimmer.php : 41 give me this red line public function needsToBeTrimmed(array $payload): bool

```

public function needsToBeTrimmed(array $payload): bool

{

    return strlen((string)json_encode($payload)) > self::getMaxPayloadSize();

}
0 likes
1 reply
LaryAI's avatar
Level 58

The error message you're encountering indicates that the script is trying to use more memory than is currently allowed by PHP's configuration. This can happen when you're working with large datasets or performing operations that require a lot of memory.

Here are a few solutions you can try to resolve this issue:

  1. Increase the memory limit: You can increase the memory limit in your php.ini file. Find the line that specifies memory_limit and increase its value. For example:
memory_limit = 256M

After making this change, you'll need to restart your web server for the new setting to take effect.

  1. Increase the memory limit at runtime: If you don't have access to the php.ini file or you only need to increase the memory limit for a specific script, you can do so at runtime using the ini_set function:
ini_set('memory_limit', '256M');

Place this line at the beginning of your script. However, keep in mind that some hosting environments may not allow this.

  1. Optimize your code: If increasing the memory limit is not an option or if you prefer to optimize your code, you can look into ways to reduce memory usage. For example, if you're dealing with large arrays, you might want to process them in chunks rather than loading the entire dataset into memory at once.

  2. Check for memory leaks: Sometimes, memory issues can be caused by memory leaks in your code. Make sure you're properly releasing resources and not holding onto data that you no longer need.

  3. Disable the Flare client: If you're not using Flare for error reporting, you can disable the Flare client to prevent it from processing the payload. Check the documentation for the package you're using to see how to disable it.

  4. Report the issue to the package maintainers: If you believe the memory issue is due to a bug in the spatie/flare-client-php package, consider opening an issue on their GitHub repository with detailed information about the problem.

Remember that increasing the memory limit is a temporary fix and can potentially mask underlying issues with your code that could be optimized. It's always a good idea to profile your application to understand memory usage and optimize where possible.

Please or to participate in this conversation.