XStream
  1. XStream
  2. XSTR-264

Methods from class 'FastStack' don't nullify references

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.3
    • Component/s: None
    • Labels:
      None

      Description

      The methods 'pop' and 'popSilently' from class 'FastStack' don't
      nullify the reference to the object being popped, which prevents them
      from being garbage collected.

      So, instead of

      public void popSilently()

      { this.pointer--; }

      public Object pop()

      { return this.stack[--this.pointer]; }

      I suggest this:

      public void popSilently()

      { this.stack[--this.pointer] = null; }

      public Object pop()

      { final Object result = this.stack[--this.pointer]; this.stack[this.pointer] = null; return result; }

      Or is there a reason not to do so ? Setting to null does take more
      time than doing nothing, but I think the added overhead is negligible
      in face of a better garbage collection.

      What do you think ?

        People

        • Assignee:
          Unassigned
          Reporter:
          Elifarley Callado Coelho
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: