hiohiohio / omegat-plugin-linkbuilder

LinkBuilder plugin for OmegaT
https://hiohiohio.github.io/
Apache License 2.0
2 stars 1 forks source link

Thread pool not closed #3

Open amake opened 8 years ago

amake commented 8 years ago

(This issue is essentially moot since this plugin is integrated with OmegaT 3.5.3 where the issue is fixed, and earlier versions of OmegaT are not getting new features. I'm reporting just to be thorough.)

The current implementation uses a ScheduledExecutorService to schedule refreshes of the linkified JTextPane's attributes. The intent appears to be to coalesce multiple updates for performance reasons.

This architecture results in a new thread pool being created for every instance of AttributeInserterDocumentFilter; these pools are never stopped, and they outlive their parents, so you can get orphaned thread pools piling up.

This plugin happens to only linkify specific, long-lived JTextPanes so it ends up being OK in the current use case. However I use OmegaT with some custom UI components that create and discard many temporary JTextPanes, and I found that if I linkified them with this component I would quickly exhaust the OS thread limit and start getting OutOfMemoryErrors.

I think thread pools are likely unnecessarily heavyweight for this application. Instead I think the most appropriate mechanism is javax.swing.Timer; see here for my modified implementation in OmegaT 3.5.3: https://sourceforge.net/p/omegat/svn/7878/#diff-1

hiohiohio commented 8 years ago

Thank you for the feedback. I am going to change this in the future.