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


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved Frequent "java.lang.OutOfMemoryError: Java heap space" errors

    Metabase
    memory
    4
    6
    527
    Loading More Posts
    • 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.
    • jamesgallagher
      jamesgallagher last edited by girish

      I'm getting errors about the Java heap space fairly regularly (see sample below). They appear to take the Metabase app down. I had previously pushed the memory up on <my cloudron>/#/app/d00ef8b7-e3a6-43e3-8c3c-73d822c1fded/resources to 3GB but the container doesn't appear to hit that. A quick scan of Metabase docs seems to indicate there's an assumption the JVM will sensibly allocate memory but I'm wondering if it's not doing that under Docker operating conditions? I can't see an obvious way of passing in a Java option to explicitly set the heap size. Anyone else hit an issue like this? (I don't think I'm running anything too heavy in Metabase)

      2020-11-02T16:02:01.000Z 2020-11-02 16:01:56,367 WARN strategy.EatWhatYouKill ::
      2020-11-02T16:02:01.000Z java.lang.OutOfMemoryError: Java heap space
      2020-11-02T16:02:01.000Z Exception in thread "MetabaseScheduler_QuartzSchedulerThread" java.lang.OutOfMemoryError: Java heap space
      2020-11-02T16:02:01.000Z 2020-11-02 16:02:01,028 WARN io.ManagedSelector :: java.lang.OutOfMemoryError: Java heap space
      2020-11-02T16:02:01.000Z 2020-11-02 16:02:01,089 ERROR sync.util :: Error fingerprinting Table 8 'hars'
      2020-11-02T16:02:01.000Z org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
      2020-11-02T16:02:01.000Z at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:337) ~[metabase.jar:?]
      2020-11-02T16:02:01.000Z at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:446) ~[metabase.jar:?]
      2020-11-02T16:02:01.000Z at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:370) ~[metabase.jar:?]
      2020-11-02T16:02:01.000Z at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:149) ~[metabase.jar:?]

      jamesgallagher 1 Reply Last reply Reply Quote 0
      • girish
        girish Staff last edited by

        This looks like we have to set the java VM heap size (like -Xms1024m -Xmx1024m). Let me check why it's not getting set to something sensible by default.

        1 Reply Last reply Reply Quote 1
        • girish
          girish Staff last edited by

          @jamesgallagher I have fixed the package to set the heap size. It was also recommended in the upstream docs - https://www.metabase.com/docs/latest/troubleshooting-guide/running.html

          jimcavoli 1 Reply Last reply Reply Quote 1
          • jimcavoli
            jimcavoli App Dev @girish last edited by

            @girish Thanks for taking care of that! I had done some fixed version of that and meant it to be variable but I guess that didn't hit the initial packaging.

            1 Reply Last reply Reply Quote 1
            • jamesgallagher
              jamesgallagher @jamesgallagher last edited by

              Thanks for looking into this and apologies for not following up - need to check my notification settings. (also work has been really busy so no mental energy for looking at my outside interests!)

              1 Reply Last reply Reply Quote 1
              • M
                markvanber last edited by

                Usually, this error is thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

                Therefore you pretty much have two options:

                • Increase the default memory your program is allowed to use using the -Xmx option (for instance for 1024 MB: -Xmx1024m)

                • Modify your program so that it needs less memory, using less big data structures and getting rid of objects that are not any more used at some point in your program

                Increasing the heap sizeis a bad solution, 100% temporary. It will crash again in somewhere else. To avoid these issues, write high performance code:

                • Use local variables wherever possible.
                • Make sure you select the correct object (EX: Selection between String, StringBuffer and StringBuilder)
                • Use a good code system for your program(EX: Using static variables VS non static variables)
                • Other stuff which could work on your code.
                • Try to move with Multy Threading
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB