Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 216289

Summary: GroupRequest#setEditPart(EditPart part) does not take care of memory
Product: [Tools] GEF Reporter: Mariot Chauvin <mariot.chauvin>
Component: GEF-Legacy GEF (MVC)Assignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: hudsonr, nyssen
Version: 3.2.1   
Target Milestone: 3.10.0 (Mars) M1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
example project
none
screenshot of current implementation debug
none
screenshot 2 of current implementation debug
none
screenshot of better implementation debug
none
screenshot 2 of better implementation debug none

Description Mariot Chauvin CLA 2008-01-23 10:32:34 EST
Current implementation is :


public void setEditParts(EditPart part) {
	parts = new ArrayList();
	parts.add(part);
}

The default ArrayList constructor use a table wth an initial capacity of 10 !

A more memory friendly implementation will be :

public void setEditParts(EditPart part) {
	parts = new ArrayList(0);
	parts.add(part);
}
Comment 1 Randy Hudson CLA 2008-01-23 13:39:19 EST
Can you please provide data showing the memory problem and the differences made by the proposed change?
Comment 2 Mariot Chauvin CLA 2008-01-24 03:58:16 EST
Created attachment 87741 [details]
example project
Comment 3 Mariot Chauvin CLA 2008-01-24 03:59:22 EST
Created attachment 87742 [details]
screenshot of current implementation debug
Comment 4 Mariot Chauvin CLA 2008-01-24 03:59:58 EST
Created attachment 87743 [details]
screenshot 2 of current implementation debug
Comment 5 Mariot Chauvin CLA 2008-01-24 04:00:26 EST
Created attachment 87744 [details]
screenshot of better implementation debug
Comment 6 Mariot Chauvin CLA 2008-01-24 04:03:26 EST
Created attachment 87745 [details]
screenshot 2 of better implementation debug
Comment 7 Mariot Chauvin CLA 2008-01-24 04:31:19 EST
I uploaded a very small example projet you can debug, to see the difference. If you do not have time to do it, I uploaded too 4 screenshots showing the difference.

If you still don't see the benefit please have a look to :
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html#trimToSize()
Comment 8 Randy Hudson CLA 2008-01-24 17:07:14 EST
I understood that the patch saves 9 words per GroupRequest during single selection. But unless you have 10,000 GroupRequests in memory, how is this even a blip on the radar? I was hoping perhaps you had done some memory profiling in a tool like YourKit that showed substantial use of some application's memory was being consumed by GroupRequests.
Comment 9 Alexander Nyßen CLA 2014-08-10 17:38:30 EDT
Ensure GroupRequest#setEditParts(EditPart) creates array list with initial capacity of 1. Fix pushed to origin/master. Resolving as fixed in 3.10.0M1