Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-438

File handles are leaked when loading images from a jar file, Tomcat crashes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.5
    • 1.2.6, 1.3.0-beta1
    • wicket
    • None
    • java version "1.5.0_07", Mac OS X 10.4, Tomcat 5.5.20
      and also
      java version "1.5.0_07", Linux 2.6.8, Tomcat 5.5.17
      Firefox 2.0.3 with Web developer Toolbar

    Description

      Wicket leaks file handles when it accesses image files that are part of a jar file, e.g. wicket-1.2.5.jar.

      To reproduce this bug, please switch off the browser cache.

      My Wicket application uses TreeTable. When I access the page with the TreeTable on my Mac server, I see the number of open file handles jump. If I do that repeatedly, I can leak about 50 file handles.

      I observe the number of open file handles via this shell command: while true; do sleep 1; lsof | grep wicket | wc -l; done

      If I do the same test on a Linux server, the number of open files jumps so quickly that I reach 1015 open files after about 4 requests. At this point, Tomcat runs out of file handles, writes a log entry in catalina.out and dies. Probably Tomcat shouldn't crash, but the problem is that Wicket leaks file handles.

      I can also see leaked file handles when I repeatedly access an image from a jar file via http://localhost:8070/wicket-examples/ajax/resources/wicket.extensions.markup.html.tree.DefaultAbstractTree/res/tree-images.png

      The problem can also be reproduced via wicket-examples 1.2.5 and its TreeTable example page by exanding and collapsing the tree table repeatedly.

      If I unpack both wicket-1.2.5.jar and wicket-extensions-1.2.5.jar in WEB-INF/classes and delete the jars afterwards, the number of used file handles remains constant at 5! So access to images in WEB-INF/classes works fine.

      "lsof | grep wicket" gives me:

      firefox-b 1372 stefan 19r REG 14,2 486664 1733273 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      bash 1880 stefan cwd DIR 14,2 578 1058285 /Users/stefan/Software/wicket-1.2.5
      bash 4339 stefan cwd DIR 14,2 578 1058285 /Users/stefan/Software/wicket-1.2.5
      java 9529 stefan txt REG 14,2 1249210 1750285 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-1.2.zoomos-SNAPSHOT.jar
      java 9529 stefan txt REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan txt REG 14,2 11063 1750305 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-spring-annot-1.2.5.jar
      java 9529 stefan txt REG 14,2 24890 1750306 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-spring-1.2.5.jar
      java 9529 stefan 29r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 30r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 31r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 32r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 33r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 34r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 35r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 36r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 37r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 38r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 39r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 40r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      java 9529 stefan 41r REG 14,2 486664 1750274 /Users/stefan/Software/apache-tomcat-5.5.20/webapps/middletier/WEB-INF/lib/wicket-extensions-1.2.5.jar
      [...many lines like this deleted]

      Attachments

        1. UrlResourceStream.java
          7 kB
          Stefan Wille

        Activity

          People

            jcompagner Johan Compagner
            stefanwille Stefan Wille
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: