glassfish
  1. glassfish
  2. GLASSFISH-4949

print(char) does too much memory allocation

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: V3
    • Fix Version/s: not determined
    • Component/s: performance
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      4,949
    • Status Whiteboard:
      Hide

      gfv3-prelude-included

      Show
      gfv3-prelude-included
    • Tags:

      Description

      Hi all,
      I just ran the following Servlet on the latest GlassFish V3 (April 21)

      protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException

      { ServletOutputStream out = response.getOutputStream(); response.setContentType("text/html"); response.setHeader("pragma", "no-cache"); String sizeStr = request.getParameter("size"); int size=0; if (sizeStr!=null) size=Integer.parseInt(sizeStr); for (int i=0; i<size;i++) out.print((char)(255*Math.random())); }

      With an reponse of 100000 (configurable by the size parameter of the servlet)
      bytes 20Mbyte are allocated.

      Profiling indicates that
      org.apache.coyote.tomcat5.CoyoteOutputStream.print(java.lang.String)
      calling

      com.sun.grizzly.util.buf.C2BConverter.convert(java.lang.String)

      which calls

      java.nio.ByteBuffer.wrap(byte[], int, int) 100000 times as well as
      java.nio.CharBuffer.wrap(char[], int, int) 100000 times.

      The response time is 3 times slower than when using write on the Outputstream,
      which allocates almost nothing except a Directbuffer.

      Regards,
      Markus

        Activity

        kohlerm created issue -
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 4949 36553
        Tom Mueller made changes -
        Fix Version/s not determined [ 11149 ]
        Fix Version/s V3 [ 10981 ]

          People

          • Assignee:
            Scott Oaks
            Reporter:
            kohlerm
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: