Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-37

PriorityQueue.clear() does not set last element to null

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/other
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Bugzilla Id:
      9454

      Description

      The code for the clear() method of the PriorityQueue in 1.4 rc5 and the nightly
      CVS of 27/04/2002 does not set the last element in the array to null, so its
      contents can be garbage-collected.

        Activity

        Hide
        otis@apache.org Otis Gospodnetic added a comment -

        Are you sure about that?
        This is what the code looks like. As far as I can tell this should take care of
        the last element, as well, no?

        public final void clear()

        { for (int i = 0; i < size; i++) heap[i] = null; size = 0; }
        Show
        otis@apache.org Otis Gospodnetic added a comment - Are you sure about that? This is what the code looks like. As far as I can tell this should take care of the last element, as well, no? public final void clear() { for (int i = 0; i < size; i++) heap[i] = null; size = 0; }
        Hide
        otis@apache.org Otis Gospodnetic added a comment -

        You are right. The heap actually puts the first element at heap[1] and not
        heap[0] like I thought, so the for loop in the clear() method had to be changed to:

        public final void clear() {
        for (int i = 0; i <= size; i++)
        heap[i] = null;
        size = 0;
        }

        Thanks for the report.

        Show
        otis@apache.org Otis Gospodnetic added a comment - You are right. The heap actually puts the first element at heap [1] and not heap [0] like I thought, so the for loop in the clear() method had to be changed to: public final void clear() { for (int i = 0; i <= size; i++) heap [i] = null; size = 0; } Thanks for the report.

          People

          • Assignee:
            java-dev@lucene.apache.org Lucene Developers
            Reporter:
            m.j.bomhoff@student.utwente.nl Matthijs Bomhoff
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development