[Biojava-l] infinite alphabets

Thomas Down td2@sanger.ac.uk
Thu, 18 Jul 2002 18:13:44 +0100


On Wed, Jul 17, 2002 at 11:56:42PM +0100, Matthew Pocock wrote:
> 
> So - symbols from infinite alpahbets are now cannonicalized. If you get 
> the Symbol instance for 365 from IntegerAlphabet seven times, you will 
> get the same object 7 times. This makes life much easer for things like 
> probabilities over integer ranges.
> 
> One more inconsistency squashed ;-)

Be careful with this -- there was a memory leak (potentially
quite large, depending on exactly what you were doing) in this
code.  I've fixed this now, and ported the new code to DoubleAlphabet,
too, and fixed another bug in that class.  If you use either
IntegerAlphabet or DoubleAlphabet from CVS, please update to
the latest versions ASAP.

Moral of the story: the Reference objects are really cool for
this kind of application, but it's quite easy to clog up memory
with dead References.  If you create a large number of them,
ensure that they are added to a ReferenceQueue, and poll this
regularly to get rid of of dead Reference objects.

I think it may also be worth giving the same treatment to
some of the cross-product Alphabet implementations which are
floating around.

     Thomas.