Reputation: 59
When a SelectionKey is cancelled and the next select operation removes the key from the key set does that free up the reference to whatever was stored in the key's attachment?
So long as one had not made any other references to the attached Object that would mean the garage collect would rid the attachment.
Am I correct?
Upvotes: 4
Views: 116
Reputation: 59
The entire SelectionKey instance is lost when the select operation removes it from the key set. The cancelled-keys set does not hold onto old keys after a selection process. The attachment isn't going to survive due to the SelectionKey itself being lost.
Upvotes: 2