Re: Memory Leaks & Strings
Laura P <email@example.com> wrote:
> I am currently going through a large program trying to root out memory
> leaks. I have found a number of instances where I am converting a
> number to a String by appending an empty String to it i.e.
> double preferredSize = s.readDouble();
> properties.setProperty("preferredWidth", preferredSize+"");
> I am not sure whether memory efficiency could be improved by doing
> this in a different way. In other concatenation instances, I have
> changed to using StringBuffers, alternatively, would any difference be
> made by using preferredSize.toString()?
> If one of these approaches is preferable, how significant would the
> change be to efficiency? I do use the technique above quite a lot...!
Executive summary: I much prefer String.valueOf(preferredSize)
Jon Skeet - <firstname.lastname@example.org>
If replying to the group, please do not mail me too
|All times are GMT. The time now is 12:50 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.