Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps - Status | Demo | Docs | Install
  1. Cloudron Forum
  2. Shaarli
  3. App crashing frequently throws "500" error - PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

App crashing frequently throws "500" error - PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

Scheduled Pinned Locked Moved Solved Shaarli
10 Posts 2 Posters 2.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SansGuidonS Offline
    SansGuidonS Offline
    SansGuidon
    wrote on last edited by SansGuidon
    #1

    my Shaarli app on Cloudron frequently throws 500 while loading the frontend.
    everytime this occurs I see this in Shaarli log: Mar 04 14:40:58 [Tue Mar 04 13:40:58.352043 2025] [php:error] [pid 46] [client 172.18.0.1:36306] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 9235624 bytes) in /app/code/application/bookmark/BookmarkIO.php on line 93

    I tried to increase the memory limit via Cloudron allocated resources and php.ini without improvement.

    I've also opened an issue in Shaarli repo: https://github.com/shaarli/Shaarli/issues/2130 because this I/O intensive operation for loading such a small DB (9K links) is unbelievable.
    I know CLoudron hardcodes this memory limit : https://git.cloudron.io/packages/shaarli-app/-/blob/master/Dockerfile?ref_type=heads#L31 so I first thought that my changes made to php.ini were not taken into account. I wonder also how to double check if those are really taken into account?

    Yet I also notice that Shaarli codebase contains a init.php file that hardcodes the memory limit to 128M : https://github.com/shaarli/Shaarli/blob/master/init.php#L18 so I also wonder if Cloudron php.ini makes sense.

    Thanks for your help!

    About me / Now

    1 Reply Last reply
    1
    • girishG Offline
      girishG Offline
      girish
      Staff
      wrote on last edited by
      #2

      @SansGuidon I can update PHP to 8.3 and see if that helps.

      One angle is: shaarli runs with a memory limit at container level. apache spins out processes and each of this has a php limit. It is possible that if apache spins say 5 processes, then 5*128MB > container limit . So, can you try adjusting the app memory limit to say 800MB and checking if that helps ? If that's the case, we can also adjust the package to use a better default memory limit.

      1 Reply Last reply
      1
      • SansGuidonS Offline
        SansGuidonS Offline
        SansGuidon
        wrote on last edited by
        #3

        Thank you @girish

        I've already pushed the memory limit up to 1G yesterday without help
        What I did try is to edit php.ini with something like

        disable_functions = ini_set
        auto_prepend_file = /app/data/init.php
        

        and the init.php was a custom hack looking like

        <?php
        $original_ini_set = 'ini_set';
        function ini_set($option, $value) {
            if ($option === 'memory_limit') {
                return false;
            }
            return call_user_func_array($GLOBALS['original_ini_set'], func_get_args());
        }
        call_user_func($original_ini_set, 'memory_limit', '512M');
        error_log("Prepend file loaded and memory_limit set to " . ini_get('memory_limit'));
        

        I don't recall all the different versions of the setting I've tried as it was passed midnight but at some point I could work around the hardcoded memory limit of 128M as defined in Shaarli init.php. Yet that didn't solve the root cause 😞

        but even if I could see an effective increase of memory limit used by Shaarli at runtime, so completely ignoring what was hardcoded in init.php , that didn't improve the situation

        About me / Now

        1 Reply Last reply
        1
        • SansGuidonS Offline
          SansGuidonS Offline
          SansGuidon
          wrote on last edited by
          #4

          @girish thanks for the package update, it might have improved the stability as despite sress testing the shaarli app after updating I didn't face the same error as before. I consider that if this resolves the problem it is a big victory, yet I prefer to not jump to conclusions for now, a good night is needed it the problem is not solved, I should soon get new alerts. Otherwise then I'll mark the issue as solved (hopefully) 🙏

          About me / Now

          1 Reply Last reply
          0
          • SansGuidonS Offline
            SansGuidonS Offline
            SansGuidon
            wrote on last edited by SansGuidon
            #5

            So far, no crash during the night 🕺 . I'm now testing if lowering the memory allocated to this app by Cloudron will make things worse. Like going back to something like 256M instead of 1G.

            About me / Now

            1 Reply Last reply
            1
            • SansGuidonS Offline
              SansGuidonS Offline
              SansGuidon
              wrote on last edited by
              #6

              @girish As mentioned before, Shaarli hardcodes the memory limit in their init.php. I did not realize that Shaarli maintainer wasn't aware of that. Yet they suggest adjusting the way Cloudron packages Shaarli. https://github.com/shaarli/Shaarli/issues/2130#issuecomment-2726974132

              Quoting the GitHub discussion:
              @nodisc said in App frequently returns 500 error - PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (cloudron) #2130

              @SansGuidon wow, I had no idea this was actually in the code (and always has been), and on my setup (apache+php-fpm) it doesn't have any effect (memory_limit stays at 256M), but I suspect it does with Cloudron's setup which still uses the deprecated apache2+mod_php setup.
              Before moving forward, I suggest that cloudron's packaging should be modernized to use php-fpm + apache mpm-event which has many advantages

              They suggest that we verify this by hacking the init.php of Shaarli and remove the ini_set but I can't do that as init.php is part of /app/code and I do not want to break Shaarli on my Cloudron 🙂

              Any idea to move this forward?

              About me / Now

              1 Reply Last reply
              0
              • girishG Offline
                girishG Offline
                girish
                Staff
                wrote on last edited by
                #7

                @SansGuidon I think it makes sense to move the package to php-fpm . We will look into that

                1 Reply Last reply
                1
                • SansGuidonS Offline
                  SansGuidonS Offline
                  SansGuidon
                  wrote on last edited by
                  #8

                  Hey, I've an update to report on this:
                  I had recently lot of crashes of my Shaarli instance that I couldn't explain nor troubleshoot. I was also convinced I should migrate away from Shaarli to fix my suffering. But with patience and being stubborn, come great success! A Shaarli plugin was it seems causing lot of troubles: https://github.com/ilesinge/shaarli-related, this plugin was causing memory exhausted issues on many pages of Shaarli.
                  Disabling it solved all my php memory exhausted issues.

                  Hope it helps!

                  Related GH issues:

                  • https://github.com/shaarli/Shaarli/issues/2130#issuecomment-2917570457
                  • https://github.com/shaarli/Shaarli/issues/953#issuecomment-2917561291

                  About me / Now

                  1 Reply Last reply
                  3
                  • SansGuidonS Offline
                    SansGuidonS Offline
                    SansGuidon
                    wrote on last edited by
                    #9

                    @girish This can be flagged as solved.

                    About me / Now

                    1 Reply Last reply
                    1
                    • jamesJ james has marked this topic as solved on
                    • SansGuidonS Offline
                      SansGuidonS Offline
                      SansGuidon
                      wrote on last edited by
                      #10

                      For the sake of completion,
                      The UptimeKuma chart for past week show a huge gain in responsiveness and stability since after disabling completely the plugin.

                      1000087733.jpg

                      About me / Now

                      1 Reply Last reply
                      2

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Bookmarks
                      • Search