Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6581437

SSLEngine wastes over 32K per instance

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0, 6
    • security-libs
    • generic, x86
    • generic, windows_xp

      A DESCRIPTION OF THE REQUEST :
      SSLEngine was created for the use with NIO. NIO was created for servers handling a very large number of concurrent connections.

      SSLEngine, however, wastes over 32K in two 16K buffers kept in EngineInputRecord and EngineOutputRecord.

      Hence, every dormant connection using SSLEngine will waste over 32K of buffers that the server code cannot even ask the SSLEngine to release when not in-use.

      JUSTIFICATION :
      Wasting 32K of memory limits the number of concurrent connections that an NIO server can handle, thereby reducing the usability of SSLEngine in providing SSL/TLS security for such a server.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect that SSLEngine not to hold strong references to 32K of memory "just in case" when the memory is not needed.

      At best, I would have the SSLEngine constructor take a parameter that would define the buffering strategy:

      1. Hold strong references (i.e. current behavior)

      2. Hold soft references (i.e. keep the buffers allocated, but let GC reuse the memory when running out of memory) . There are problems with this method, too, since it may interfere with other caching activities that the server may want to engage in.

      3. Allocate the buffers only when needed and get rid of them when not needed. This will cause more array allocations but may save a ton of memory.
      ACTUAL -
      The SSLEngoine just hoggs over 32K memory and keeps it allocated "just in case", even if it is not used for a long time.

            xuelei Xuelei Fan
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: