3 Replies Latest reply: Dec 13, 2011 6:23 PM by jschellSomeoneStoleMyAlias RSS

    JVM not releasing memory back after consuming

    905023
      We have an application which use about 150m on heap after startup,
      but some task can make the memory grow up to 700m.
      The problem is that after the "memory consuming" task, the JVM don't release it.

      So, here is my question : How can I be sure after a memory consuming task that the JVM won't keep the memory for itself when
      the really used memory is about 150m and the allocated size is about 1gb ? is there any clean way to notify the JVM that this memory usage was really
      temporary and that it should release it for other application ?


      Thanks,
      Phanikanth
        • 1. Re: JVM not releasing memory back after consuming
          gimbal2
          That's expected and documented behavior that exists for very valid reasons. If you really must know the how and why, there is plenty of information available like this whitepaper:

          http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf

          Remember: the JVM is a virtual machine which deals with its own memory management. The last thing you want to do is mess with it.
          • 2. Re: JVM not releasing memory back after consuming
            jschellSomeoneStoleMyAlias
            902020 wrote:
            ... and that it should release it for other application ?
            All modern desktops use virtual memory. That is a feature of the OS which impacts all normal applications including Java VMs.

            Some features of virtual memory.
            1. Applications have their own addressable memory which is not impacted by other application (normal) usage.
            2. Memory that is reserved by an application which is not being actively used does not impact other applications.
            • 3. Re: JVM not releasing memory back after consuming
              EJP
              How can I be sure after a memory consuming task that the JVM won't keep the memory for itself
              You can't, because it will.

              This only costs you disk space.