traff/jediterm — pull request #37 by Plonk42 (2013-07-30 16:48:57+00:00)
Title: Fix memory leak when JediTerm is used in another application

Some memory leaks occur when we open and close JediTerm.
This is critical when we use a lot of JediTerm instances in a single process.

1) one is due the TerminalStarter executor, which does not clear its thread until explicitly shut down.
This leaks one thread per terminal instance.

To fix this, I assumed that once a TerminalStarter has been closed, we won't open it again.
There is no way to restart the executor once the TerminalStarter has been closed with this patch.
I don't think this is an issue, but we can simply fix it if needed.

2) the Swing timer used to redraw the terminal panel keeps a reference to this panel, retaining a massive dominator tree (almost all what is instantiated by JediTerm :) ).
To fix this, I've implemented a kind of WeakRedrawTimer, which use a WeakReference to the panel, so it don't retain it. I find it to be simpler and cleaner than trying to track when we don't need the panel anymore, which is hardly doable without explicitly unregister the timer : this would need some access to the timer, and is leak prone.