Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318820 - EclipseContext does unnecessary object allocations
Summary: EclipseContext does unnecessary object allocations
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-04 16:25 EDT by Stefan Mücke CLA
Modified: 2011-05-17 16:25 EDT (History)
4 users (show)

See Also:


Attachments
Proposed patch for EclipseContext.dispose() (2.80 KB, patch)
2010-07-04 16:25 EDT, Stefan Mücke CLA
ob1.eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Mücke CLA 2010-07-04 16:25:14 EDT
Created attachment 173380 [details]
Proposed patch for EclipseContext.dispose()

EclipseContext does unnecessary object allocations.

I found this problem when I wanted to create a temporary EclipseContext as follows:

IEclipseContext context = EclipseContextFactory.create();
// ... set some values
context.set(key, value);
context.setParent(parentContext);
// ... do something with the context
context.dispose();

I expected that creating a context without a parent and setting some values should be a cheap operation. But, even though there are no listeners installed on the context, there is a lot of overhead when the context is changed.

For example, the EclipseContext.dispose() method will always create a HashSet, an EclipseContext[]-array, and a Computation[]-array regardless of whether there are listeners.
Comment 1 Oleg Besedin CLA 2010-07-06 10:19:00 EDT
Nice catch, thanks Stefan!

Patch applied to CVS Head.