Search:

Type: Posts; User: KevinWorkman

Search: Search took 0.46 seconds.

  1. [SOLVED] Re: ArrayList memory bloat that I cannot comprehend

    I suspect that you're experiencing a slightly different problem- even with the worst coding practices, using String concatenation in a loop shouldn't give you an OutOfMemoryError, it'll just use up...
  2. [SOLVED] Re: ArrayList memory bloat that I cannot comprehend

    Sorry, I actually read it wrong- I didn't realize you were calling new String(string). That actually does create a new instance of String. You can test this by using the == operator on the original...
  3. [SOLVED] Re: ArrayList memory bloat that I cannot comprehend

    Your new loop is still allocating a new instance of String each iteration. It has less overhead because it's only using a single instance of StringBuilder, but you're still creating a new String each...
  4. [SOLVED] Re: ArrayList memory bloat that I cannot comprehend

    The whole point is that the second loop is allocating a lot more instances, either of String or of a String array depending on which version of the code we're looking at. The first loop is only...
  5. [SOLVED] Re: ArrayList memory bloat that I cannot comprehend

    To show what I mean, try this as your first loop:


    ArrayList<String> list = new ArrayList<String>();
    for(int i = 0; i <= 1000000; i++)
    {
    list.add(new String(line));
    }
  6. [SOLVED] Re: ArrayList memory bloat that I cannot comprehend

    Well, you're doing two very different things here: in the first loop, you're adding the same instance of String to a List over and over again. That's not going to take up much memory. In the second...
  7. [SOLVED] Re: ArrayList memory bloat that I cannot comprehend

    There are a couple misunderstandings here.

    The value returned by Runtime.totalMemory() isn't what your program is currently using- it's how much total memory it has had to use. Java allocates...
Results 1 to 7 of 7