Eclipse LaunchConfigurationDelegate prone to memory leaks

LaunchConfigurationDelegates in Eclipse remain in memory after their launch method has executed. As such, they also prevent any object they reference from being garbage-collected. For example in the following code

class MyLaunchConfigurationDelegate extends LaunchConfigurationDelegate {

    protected BigObject bigObject = null;

    public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor progressMonitor) throws CoreException {
        this.bigObject = createBigObject();		
    }
}

bigObject will remain in memory for ever, so it’s worth keeping this in mind and cleaning up before returning from launch().

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s