4 Replies Latest reply on Oct 9, 2015 12:19 AM by Brendan Edmonds

    Debugging on wildfly

    Brendan Edmonds Newbie

      I have an application in production, that seems to use a lot of CPU (400%) after a couple of days. When I restart it, the application sits at about 2% randomly (usually after 2 days) it happens again. I come from a PHP background, and echo is normally the tool I use, however I feel this won't work for this problem.

       

      What is the best way to debug this type of problem in wildfly? What tools are available for debugging wildfly in general?

       

      Thanks

       

      Brendan

        • 1. Re: Debugging on wildfly
          Philippe Marschall Expert

          Brendan Edmonds wrote:

           

          I have an application in production, that seems to use a lot of CPU (400%) after a couple of days. When I restart it, the application sits at about 2% randomly (usually after 2 days) it happens again.

          ...

          Could be garbage collection related. Either not enough heap or a memory leak.

          Brendan Edmonds wrote:

           

          ... I come from a PHP background, and echo is normally the tool I use, however I feel this won't work for this problem.

           

          What is the best way to debug this type of problem in wildfly? What tools are available for debugging wildfly in general?

          Tools like Oracle Mission Control are very powerful. However it does require a license for use in production. If you don't have that and can't reproduce the problem in QA or development I would do the following:

          • Run jmap -heap to make check if you're running out of heap.
          • If you're running out of heap do a heap dump with jcmd and check if you're having a leak. If you have a leak fix it, if you don't have a leak give the application more heap.
          • If you're not running out of heap run jcmd to print the stack traces of all threads and see where you're spending time.
          • 2. Re: Debugging on wildfly
            Wolfgang Mayer Master

            Maybe you could also try the Eclipse Memory Analyzer (Eclipse Memory Analyzer Open Source Project)

            • 3. Re: Debugging on wildfly
              Philippe Marschall Expert

              Yes, I would also recommend MAT for heap dump analysis.

              • 4. Re: Debugging on wildfly
                Brendan Edmonds Newbie

                Found the issue. I was having problems with the quality of images when I resized them.

                 

                I was trying to resize a 1371x958 image down to a 340x237. After Googling for a couple of hours, I found a solution that did the following:

                 

                 

                do {
                     System.out.println("image");
                     if (higherQuality && w > targetWidth) {
                          w /= 2;
                          if (w < targetWidth)
                               w = targetWidth;
                     }
                
                     if (higherQuality && h > targetHeight) {
                          h /= 2;
                          if (h < targetHeight)
                               h = targetHeight;
                     }
                
                
                     final BufferedImage tmp = new BufferedImage(w, h, type);
                     final Graphics2D g2 = tmp.createGraphics();
                     g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
                     g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
                     g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                     g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
                     g2.drawImage(ret, 0, 0, w, h, null);
                     g2.dispose();
                
                
                     ret = tmp;
                } while (w != targetWidth || h != targetHeight);
                

                 

                 

                Which works when your shrinking images, however when the width or height of the image is smaller than target, it goes into an endless loop.