6 Replies Latest reply on Nov 10, 2017 6:23 AM by jaikiran pai

    Wildfly 10 Consumes a lot of Memory

    Ali Hopyar Newbie

      I deploy 4 different war in a clustered environment on Wildfly 10 and Wildfly consumes a lot of memory.

       

       

      My configuration on standalone.conf is;

       

       

          ...

          JAVA_OPTS="-Xms256m -Xmx1400m -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=320m -Djava.net.preferIPv4Stack=true"

          ...

       

       

      After Wildfly started, it takes 1.7 GB of memory and it increases to 1.8 GB in a short time.

       

       

      Why Wildfly starts with using so much memory?

       

       

      What is the reason of this and how can I prevent from this situation.

        • 1. Re: Wildfly 10 Consumes a lot of Memory
          William Darby Newbie

          If you are using Java8, one thing you can do is determine where the memory is being used by tracking the native memory with

          -XX:NativeMemoryTracking=summary

           

          Then you can periodically inspect it with:

          $ jcmd <pid> VM.native_memory summary

           

          This gives you insight into memory used by threads, classes, heap, GC, etc.

          I found that WF 10 started an excessive number of threads based on the number of CPUs it detected.

          • 2. Re: Wildfly 10 Consumes a lot of Memory
            Frank Langelage Master

            How do you measure the memory consumption? Which platform you're using (Windows, Linux, Solaris, ...)?

            As max heap and max metaspace are set to 1400m and 320m the process needs to reserve ~1,7 GB of memory.

            But this does not mean it actually allocated that much.

            • 3. Re: Wildfly 10 Consumes a lot of Memory
              Wolf-Dieter Fink Master

              For performance reason I would use "-Xms == -Xmx", that will alocate the complete memory and prevent from recalculating.

              The JMV might decide to allocate memory between min and max, but you need to enable the GC logging to see what the JVM really use.

              Also you should notice that the JVM consume -Xmx + -MaxMetaSpace + ThreadStack + internal areas. So the allocated memory is a bit more than what the parameters are.

              • 4. Re: Wildfly 10 Consumes a lot of Memory
                Ali Hopyar Newbie

                Hi Frank;

                 

                I use a Linux distribution Amazon EC2 supply. After I started the Wildfly, I run 'top' command and java is the top of them which consumes 1.7gb of memory as I mentioned on the question. I have 2gb of memory in total so it gives me so much trouble. I would think Wildly will consume 1.7gb of memory if necassary but it takes all of them at start. I can start Wildfly with 1 gb of Memory in total by changing the parameters but in some cases that may not be enough. This is the reason why I give max 1.7 gb of ram in total. Is there someting I can do what I want.

                • 5. Re: Wildfly 10 Consumes a lot of Memory
                  Laura delli Paoli Master

                  Did you solve this problem? I'm facing a similar issue deploying Wildfly 10.1.0 on Centos7 docker containers. Memory issues are letting the kernel kill wildfly service.

                  • 6. Re: Wildfly 10 Consumes a lot of Memory
                    jaikiran pai Master

                    You can use tools like jmap (which comes bundled within the Java SDK) to get the memory usage details of the process and then analyze it to see what is consuming that memory.