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

Bug 373010

Summary: StyledCellLabelProvider leaks element from last cell even after table/tree is cleared
Product: [Eclipse Project] Platform Reporter: Eleanor Joslin <ejj-eclipsebugs>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: ericwill
Version: 4.2Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Example program none

Description Eleanor Joslin CLA 2012-03-01 13:56:28 EST
Build Identifier: Version: 3.6.2 Build id: M20110210-1200

StyledCellLabelProvider contains a field called elementOfLastMeasure which caches the element from the last cell to be painted.  The only way to clear the cache is to dispose the StyledCellLabelProvider.

This means if a table contains some complex objects and is then emptied but not disposed, a lot of memory can be leaked.  I've just spent several hours modifying my application to work around this.

The frustrating thing is that the lines where elementOfLastMeasure is set are marked for removal if bug 228695 is fixed.  That bug is fixed but the code is still there.


Reproducible: Always

Steps to Reproduce:
The attached program (to follow) keeps a weak reference to an element in a table.  After clearing the table it performs a gc and checks whether the element is still reachable.

1. Run the attached program and observe the leak.
2. In the code, set USE_STYLED_CELL_LABEL_PROVIDER to false.
3. Run the program again - no leak.
Comment 1 Eleanor Joslin CLA 2012-03-01 13:57:10 EST
Created attachment 211906 [details]
Example program
Comment 2 Eric Williams CLA 2018-04-13 15:22:47 EDT
I cannot reproduce the issue anymore on GTK3.22, 4.8 M6, and Fedora 27.