Community
Participate
Working Groups
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
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.
No reply from submitter in years. Closing. Please reopen if/when you have time to give us a way to reproduce the leak claimed.