2 Replies Latest reply on Aug 4, 2008 4:27 AM by Boris Pophristov

    Web method memory leak?

    Boris Pophristov Newbie

      Hello,

      We have a web service for file upload/download. We are using a web method that returns a chunk of the file as a byte array for downloading. When the web service client downloads a large file the memory used by the java.exe (monitored using Windows Task Manager) swiftly increases and is never released. Eventually the used memory becomes so much that the whole computer performance decreases dramatically. Same happens if simply return a large byte array:

      @WebMethod
      public byte[] downloadChunk() {
       return new byte[524288];
      }
      


      We are using JBoss 4.2.1 GA with JBossWS 2.0.1. Java 1.5.0_15. It is running on Windows Vista 32.

      Any help on solving this will be greatly appreciated. Thank you in advance.

      BP

        • 1. Re: Web method memory leak?
          Peter Johnson Master

          If you set the min and max heap sizes to different values, then when the JVM requires more heap space it will get it from the os, after which the JVM rarely lets go of that memory, even if the space required for those objects (the byte array in this case) is cleaned up during a garbage collection. Thus the behavior you are seeing in task manager does not indicate a memory leak - it is just how Java works.

          To determine if a memory leak was taking place you would have to monitor the objects in the heap, either by monitoring the garbage collector (this lets you know if there is a possible leak but not where), or by using a tool like VisualVM which lets you take and compare heap dumps.

          • 2. Re: Web method memory leak?
            Boris Pophristov Newbie

            Peter,

            Thank you for your reply! Increasing the heap size solved my problem.

            BP