Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346815 - Memory leak in org.eclipse.swt.custom.StyledText.replaceTextRange
Summary: Memory leak in org.eclipse.swt.custom.StyledText.replaceTextRange
Status: CLOSED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-22 11:18 EDT by Eric Snellman CLA
Modified: 2017-12-05 04:27 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Snellman CLA 2011-05-22 11:18:05 EDT
Build Identifier: swt-3.7-M7

I am using the StyledText as a log widget.
I add strings with style ranges.
To reduce the size of the log I do: replaceTextRange(0, 4000, "");
If I do not add StyleRanges while still adding strings I have no memory increases over time.
I believe replaceTextRange does not destroy previous StyleRanges, it does free the text.
I also believe this issue affects previous SWT versions and thus the Eclipse IDE causing me to have to restart the IDE once a week due to memory.


Reproducible: Always

Steps to Reproduce:
Well my test is more complex but I believe it can be boiled down to:
1. append("a random string");
2. setStyleRange(SomeStaticStyleRange)
3. replaceTextRange(0, "a random string".length(), "");
4. repeat many times watch memory
Comment 1 Felipe Heidrich CLA 2011-05-24 12:17:31 EDT
Can you write up a snippet using only SWT that shows the problem ?

Note that the way the styles are being set in StyledText can change the behaviour. During the modify text operation (replaceTextRange(0, 4000, "")) StyledText only remove the StyleRange objects from its internal arrays. But it is still possible that you have references to these objets in your code, in which case the GC will not free up the memory.

In other words, StyledText does not free the StyleRange objects for you. It only removes the reference it has.



Note, I would be surprised that StyledText is leaking memory during modify text operation as that would hugely impact the entire IDE.
Comment 2 Alexander Kurtakov CLA 2017-12-05 04:27:32 EST
No reply from submitter in years. Closing. Please reopen if/when you have time to give us a way to reproduce the leak claimed.