Does using text properties cause memory leaks?

If a string is immutable, and the Text property of a text box is a string type, will that not result in a massive memory leak if my application makes a lot of changes to the text box?

What is the best practice when working with text properties that are frequently updated?

Jon Skeet
people
quotationmark

(I'm assuming you're talking about Java or .NET.)

will that not result in a massive memory leak if my application makes allot of changes to the text box

No. It may require many strings to be created, but they can then be garbage collected when they're no longer relevant... so there's no leak.

You need to be somewhat careful about how much garbage you generate, but in the case of a UI the garbage collector is likely to be significantly faster than the UI anyway - I'd expect that you'd get to the point where the UI is failing to keep up with the changes before GC churn becomes an issue.

people

See more on this question at Stackoverflow