Bug 27072 - [ActionSets] SelectionListenerAction allocates 2 * ArrayList(10) everytime selection changes
Summary: [ActionSets] SelectionListenerAction allocates 2 * ArrayList(10) everytime se...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Simon Arsenault CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2002-11-25 05:42 EST by Adam Kiezun CLA
Modified: 2002-12-17 17:37 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2002-11-25 05:42:58 EST
SelectionListenerAction calls initCollections everytime selection changes
and that allocates 2 arrays of size 10 everytime
these arrays are mostly empty

these empty arrays sum up to quite a lot of garbage after each click in the 
workbench
Comment 1 Simon Arsenault CLA 2002-12-03 11:31:44 EST
It's even worst... it calls initCollections each time the selection changes and 
then again when computeResources is call!

Also, most of these subclasses are probably hooking themselves up to listen for 
selection changes at the page level. Which mean each on of these will 
potentially compute this collection of resources/non-resources and hold onto 
this copy. Even more wasted space.
Comment 2 Nick Edgar CLA 2002-12-03 13:32:09 EST
We used to just clear out the arrays using clear() rather than recreating them.
This was changed a while back to address a race condition bug where two threads 
were accessing the lists.  See bug 8514 and bug 15769.

Should look at lazy initializing them, and using a smaller default size.
Could also consider using synchronized blocks.
Comment 3 Simon Arsenault CLA 2002-12-05 13:29:16 EST
The bug 8514 fixed a problem for a scenario like
1) updateSelection called
2) getResources called => clears current array and populates it
3) iterates over collection returned (using Iterator)
4) while processing one of the resources, some method call causes the selection 
to change
5) selectionChange is called
6) the current array is cleared => but fails because the iterator (in step 3)

For M4, we will not create the arrays until they are needed (most time the non 
resource array contains no items). We will set the initial size of the array.
Comment 4 Simon Arsenault CLA 2002-12-05 14:19:11 EST
Update the code to delay as late as possible creating new arrays and also 
providing a reasonable initial size.

Created a bug 27789 to relook at a possible better solution for this area.
Comment 5 Knut Radloff CLA 2002-12-17 17:37:53 EST
Verified fixed in 20021216