1 Reply Latest reply on Jul 23, 2010 2:17 PM by Clebert Suconic

    Use of File.deleteOnExit will leak memory.

    Lou Bershad Newbie

      This is just a warning...

       

      I noticed that org.hornetq.core.client.impl.ClientConsumerImpl uses File.deleteOnExit if session.isCacheLargeMessageClient() is true.

       

      File.deleteOnExit() keeps a list of pathnames that need to be deleted (even if File.delete() was subsequently called).

       

      See [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4513817]

      {quote}

      It would be a fairly simple matter to remove a file from the delete on
      exit list when it gets deleted, but that would be a violation of spec.
      File.deleteOnExit says "Requests that the file or directory denoted by this
      abstract pathname be deleted when the virtual machine terminates." So
      just because the file is deleted does not mean that it will not get re-opened later. The File object might even get garbage collected but another of the same
      name might be created later. We are obligated by the spec to remember the path
      and delete a file there when the VM terminates. There is no way around the
      memory leak without relaxing this spec.

      {quote}

       

      The leakage is small on a per file basis, but could add up as hornetq is a long running process.