Re: Memory Leaks & Strings

Discussion in 'Java' started by Jon Skeet, Jul 30, 2003.

  1. Jon Skeet

    Jon Skeet Guest

    Laura P <> 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...!


    See http://www.pobox.com/~skeet/java/stringconv.html

    Executive summary: I much prefer String.valueOf(preferredSize)

    --
    Jon Skeet - <>
    http://www.pobox.com/~skeet/
    If replying to the group, please do not mail me too
    Jon Skeet, Jul 30, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harald Hein

    Re: Memory Leaks & Strings

    Harald Hein, Jul 31, 2003, in forum: Java
    Replies:
    1
    Views:
    392
    Laura P
    Jul 31, 2003
  2. Steven

    Re: Memory Leaks & Strings

    Steven, Aug 14, 2003, in forum: Java
    Replies:
    1
    Views:
    416
    pete kirkham
    Aug 15, 2003
  3. Steven

    Re: Memory Leaks & Strings

    Steven, Aug 14, 2003, in forum: Java
    Replies:
    1
    Views:
    339
    Chris Smith
    Aug 15, 2003
  4. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    735
    Malcolm
    Jun 24, 2006
  5. Replies:
    4
    Views:
    107
Loading...

Share This Page