Derby
  1. Derby
  2. DERBY-5873

Avoid unnecessary allocation of Number instances in client/server

    Details

    • Bug behavior facts:
      Performance

      Description

      Java 5 introduced some new static factory methods (called valueOf()) in the Number sub-classes, to be used in preference of the constructors unless a fresh instance is required. The valueOf() methods are allowed to cache and reuse objects, possibly reducing the allocation/gc cost and the memory footprint. For example, Integer.valueOf(int) uses a pre-allocated cache for values between -128 and +127 by default (the cache size can be tuned with JVM flags).

      Now that the server and client code is compiled against Java 5 libraries, we should use the valueOf() methods to get those benefits. Note also that Java 5 auto-boxing of numbers uses these methods implicitly, so in many cases we can just remove the calls to the constructor and the compiler will automatically insert the calls for us.

      1. d5873-1a.diff
        130 kB
        Knut Anders Hatlen
      2. d5873-2a-bigdec.diff
        6 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Knut Anders Hatlen made changes -
          Link This issue is related to DERBY-6391 [ DERBY-6391 ]
          Gavin made changes -
          Workflow jira [ 12717640 ] Default workflow, editable Closed status [ 12801739 ]
          Knut Anders Hatlen made changes -
          Status In Progress [ 3 ] Closed [ 6 ]
          Issue & fix info Patch Available [ 10102 ]
          Fix Version/s 10.10.0.0 [ 12321550 ]
          Resolution Fixed [ 1 ]
          Knut Anders Hatlen made changes -
          Issue & fix info Patch Available [ 10102 ]
          Priority Major [ 3 ] Minor [ 4 ]
          Knut Anders Hatlen made changes -
          Attachment d5873-2a-bigdec.diff [ 12537979 ]
          Knut Anders Hatlen made changes -
          Issue & fix info Patch Available [ 10102 ]
          Knut Anders Hatlen made changes -
          Issue & fix info Patch Available [ 10102 ]
          Knut Anders Hatlen made changes -
          Attachment d5873-1a.diff [ 12537658 ]
          Knut Anders Hatlen made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]
          Knut Anders Hatlen created issue -

            People

            • Assignee:
              Knut Anders Hatlen
              Reporter:
              Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development