Memory increase problem?

Discussion in 'Mac Programming' started by mkristain, Sep 6, 2011.

  1. mkristain macrumors regular

    Joined:
    Aug 18, 2011
    #1
    hello,

    in my for loop i check the condition and format a string and set this string on a label,so here memory is increase.
    Code:
    NSString* str=@"";
    		for(int j=0; j<512; j++)
    		{
    			str=[NSString stringWithFormat:@"Current Loop Value%d",j];
    [_test_label setStringValue:str];
    		}
    
    is there any other method to format the string set on label without increasing memory.

    thanks in advance.
     
  2. xStep, Sep 7, 2011
    Last edited: Sep 7, 2011

    xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #2
    We've been here before with you. This code is not real world. Please, stop wasting our time on such non-sense.

    BTW, no.
     
  3. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #3
    Thank you for your question.
    We appreciate your questions.
    We would also appreciate if you actually listened to any advice given.
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    You could set up an autorelease pool around the loop, or even inside the loop. The loop is useless, though, so you can really just set this using 511. Also, assigning @"" to your pointer is unnecessary. Initializing to nil is more "normal".

    -Lee
     
  5. mkristain thread starter macrumors regular

    Joined:
    Aug 18, 2011

Share This Page