private void reclaimSpace ( ) { if ( _nameMap == null ) return ; if ( _nameMap . size ( ) > 0 && _nameMap . size ( ) % _reclaimPoint == 0 ) { synchronized ( _nameMap ) { Set s = _nameMap . entrySet ( ) ; Iterator it = s . iterator ( ) ; while ( it . hasNext ( ) ) { Map . Entry e = ( Map . Entry ) it . next ( ) ; TrackingObject to = ( TrackingObject ) e . getValue ( ) ; // If the object has been reclaimed, then we remove the named object from the map. WeakReference wr = to . getWeakINameable ( ) ; INameable o = ( INameable ) wr . get ( ) ; if ( o == null ) { it . remove ( ) ; } } _reclaimPoint = _nameMap . size ( ) + _reclaimIncrement ; } } }
This mehtod will check the name map for entries where the WeakReference object has been reclaimed . When they are found it will reclaim the entry in the map .