PHP Fatal error: Allowed memory size exhausted

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wesseldejong
    Junior Member
    • Jan 2025
    • 4

    #1

    PHP Fatal error: Allowed memory size exhausted

    Dear all,
    I encountered the following problem. I am running multiple flowcharts at night and encounter the following error in the logs every morning:

    "Uncaught Exception Spatie\Async\Output\ParallelError: "PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 131072 bytes) in /var/www/html/application/Espo/ORM/BaseEntity.php on line 1080
    " at /var/www/html/vendor/spatie/async/src/Output/ParallelError.php line 11"

    I have already increased the PHP memory limit to 512M in the "espocrm.ini" file in espocrm Docker container. When I run 'php -i | grep "memory_limt"' inside the container it indeed returns a memory_limit of 512M. Finally, when I look under adminstration -> system requirements I also see memory limit is 512M.

    However, converting the number of 268435456 bytes mentioned in the error message to MB I get 256MB (Espo default I believe). Maybe I misunderstood something but can someone clarify this for me? Now I am not sure whether increasing the PHP memory limit actually worked.

    The current EspoCRM version I am working in is 8.3.21 and running nginx.

    Thanks in advance!
    Last edited by wesseldejong; Today, 10:24 AM.
  • lazovic
    Super Moderator
    • Jan 2022
    • 1136

    #2
    Hi wesseldejong,

    The following issue was discussed here: https://forum.espocrm.com/forum/inst...8-4-2-to-9-0-1.

    Comment

    • wesseldejong
      Junior Member
      • Jan 2025
      • 4

      #3
      Hi lazovic!

      Thanks for the quick response and sharing the related post. However, the resolution discussed there seems to refer to one time runs of the upgrade script with a higher php memory limit. In our case we are encountering this issue when running Advanced Package flowcharts with a timer start event. When target report includes approx more then 3000 records, the memory limit error happens.

      So in our case running through CLI with the one time increase of the php memory limit (php -d memory_limit=524M command.php <...>) does not really seem to be an option. Please let me know if I am not understanding correctly

      Comment

      • lazovic
        Super Moderator
        • Jan 2022
        • 1136

        #4
        wesseldejong,

        It seems that the new memory limit was not actually applied. The error shows 256MB limit, so the PHP are still using the default memory limit. The fix is to correctly update the CLI php.ini memory limit and validate it with the php -i command.


        Comment

        • wesseldejong
          Junior Member
          • Jan 2025
          • 4

          #5
          lazovic

          Okay to clarify my understanding; looking at the post you shared, the suggested solution would be to run something like "php -d memory_limit=524M command.php <...>". That was the solution that worked for the other post.

          Indeed it seems that the CLI php memory limit was not adjusted correctly. I only do not see how the above would change anything to that since the -d flag will only ensure the php memory_limit is changed temporarily during the run of this command. However, we are not looking for a one time solution after which memory limit can be set back to 256MB, but a structural change to 512MB such that flowcharts do not run into this limit anymore. So we are looking for a reason why the CLI php memory limit does not seem to be updated while we actually changed the memory_limit in the .ini file and the UI also mentions a limit of 512MB.

          I guess my question is how to structurally increase the memory limit for CLI if chaning the espocrm.ini file does not work (and php -i and UI indicate it did work)?

          Thanks again for your help and let me know if I missed anything
          Last edited by wesseldejong; Today, 11:58 AM.

          Comment

          Working...