[Biojava-dev] DP memory leak

Matthew Pocock matthew_pocock at yahoo.co.uk
Mon Dec 22 07:06:16 EST 2003


Hi,

Lachlan James Coin wrote:

> Hi,
>
> I came across a bit of a memory leak while using the dp code.  The 
> problem is that AlphabetManager keeps a reference to every alphabet 
> created, including StateAlphabetcreated when using the dp package.  I 
> had extended the EmissionState class in such a way that the instances 
> were of a non-trivial size.  I am also creating (one after the other) 
> a lot of different state alphabets.  The result was that I ran out of 
> memory farily quickly.

Hehe. That's an unforseen use-case bug.

>
> One possible fix I thought of was to add "deregisterAlphabet(name)" 
> method to AlphabetManager, and to call this from the finalize mehod of 
> SimpleMarkovModel, so that when the garbage collector thinks it can 
> clear the markov model the statealphabet is removed from the 
> AlphabetManager registry and can then also be garbage collected.   
> Also, it would be necessary to make alphabetToIndex a WeakHashMap.

This may work - but it adds API.

>
> Any other suggestions?  Can I make these changes?

How transparent can we make this? How easy would it be for alphabets to 
be dropped automatically when not needed any more? I guess we don't want 
to drop DNA & friends :)

>
> Thanks,
>
> Lachlan
>
Matthew



More information about the biojava-dev mailing list