Mantis - Croquet
Viewing Issue Advanced Details
3522 Hedgehog minor always 05-02-06 01:39 03-03-08 15:08
bfowlow  
andreas  
normal  
feedback  
reopened  
none    
none  
0003522: SharedQueue makeRoomAtEnd leaves references in high end of array

SharedQueue makeRoomAtEnd does a conventional downshift
of its content array but does not nil out the high end space afterword.

It can then hang on far too long to whatever object refs were left
there, so they can cannot be garbage collected until the queue walks up
to its high water mark again.

A simple fix is


makeRoomAtEnd
   | contentsSize |
    readPosition = 1
        ifTrue: [contentsArray := contentsArray , (Array new: 10)]
        ifFalse:
            [contentsSize := writePosition - readPosition.
            "BLT direction ok for this. Lots faster!!!!!! SqR!! 4/10/2000 10:47"
            contentsArray
                replaceFrom: 1
                to: contentsSize
                with: contentsArray
                startingAt: readPosition.

        "fix: clear the old upper range so we don't hoard references."
            contentsArray
                from: contentsSize+1 "new end of content"
                to: writePosition-1 "old write position"
                put: nil.

                 "fix ends"
            readPosition := 1.
            writePosition := contentsSize + 1]

The SharedQueue used by WorldState's deferredUIMessage service
(used heavily by the TMorphicForm hedgehack) is often affected by this.

Notes
(0005282)
andreas   
06-19-06 21:47   
In the repository.
(0011900)
bert   
03-03-08 15:08   
This was actually a duplicate of 0002125, but 0002708 is still unfixed in Croquet.