title: UITableView's NSString memory leak on iphone when encoding with NSUTF8StringEncoding
body: <p>my UITableView have serious memory leak problem only when the NSString is NOT encoding with NSASCIIStringEncoding.</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      static NSString *CellIdentifier = @"cell";
      UILabel *textLabel1;
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
          textLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(105, 6, 192, 22)];
  
          textLabel1.tag = 1;
          textLabel1.textColor = [UIColor whiteColor];
          textLabel1.backgroundColor = [UIColor blackColor];
          textLabel1.numberOfLines = 1;
          textLabel1.adjustsFontSizeToFitWidth = NO;
          [textLabel1 setFont:[UIFont boldSystemFontOfSize:19]];
          [cell.contentView addSubview:textLabel1];
          [textLabel1 release];
  
      } else {
          textLabel1 = (UILabel *)[cell.contentView viewWithTag:1];
      }
  
      NSDictionary *tmpDict = [listOfInfo objectForKey:[NSString stringWithFormat:@"%@",indexPath.row]];
  
      textLabel1.text = [tmpDict objectForKey:@"name"];
  
      return cell;
  }
  
  -(void) readDatabase {
      NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDir = [documentPaths objectAtIndex:0];
      databasePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",myDB]];
      sqlite3 *database;
  
      if(sqlite3_open([databasePath UTF8String], &amp;database) == SQLITE_OK) {
  
          const char sqlStatement = [[NSString stringWithFormat:@"select id,name from %@ order by orderid",myTable] UTF8String];
          sqlite3_stmt *compiledStatement;
          if(sqlite3_prepare_v2(database, sqlStatement, -1, &amp;compiledStatement, NULL) == SQLITE_OK) {
              while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
                  NSString *tmpid = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
  
  
                  NSString *tmpname = [NSString stringWithCString:(const char *)sqlite3_column_text(compiledStatement, 1) encoding:NSUTF8StringEncoding];
  
  
                  [listOfInfo setObject:[[NSMutableDictionary alloc] init] forKey:tmpid];
                  [[listOfInfo objectForKey:tmpid] setObject:[NSString stringWithFormat:@"%@", tmpname] forKey:@"name"];
  
  
              }
          }
          sqlite3_finalize(compiledStatement);
  
          debugNSLog(@"sqlite closing");
  
      }
      sqlite3_close(database);
  
  }
  </code></pre>
  
  <p>when i change the line</p>
  
  <pre><code>NSString *tmpname = [NSString stringWithCString:(const char *)sqlite3_column_text(compiledStatement, 1) encoding:NSUTF8StringEncoding];
  </code></pre>
  
  <p>to</p>
  
  <pre><code>NSString *tmpname = [NSString stringWithCString:(const char *)sqlite3_column_text(compiledStatement, 1) encoding:NSASCIIStringEncoding];
  </code></pre>
  
  <p>the memory leak is gone</p>
  
  <p>i tried NSString stringWithUTF8String and it still leak.
  i've also tried:</p>
  
  <pre><code>NSData *dtmpname = [NSData dataWithBytes:sqlite3_column_blob(compiledStatement, 1) length:sqlite3_column_bytes(compiledStatement, 1)];
  NSString *tmpname = [[[NSString alloc] initWithData:dtmpname encoding:NSUTF8StringEncoding] autorelease];
  </code></pre>
  
  <p>and the problem remains, the leak occur when u start scrolling the tableview.</p>
  
  <p>i've actually tried other encoding and it seems that only NSASCIIStringEncoding works(no memory leak)</p>
  
  <p>if i did not scroll the tableview before i close the view, it's no leak at all. actually listOfInfo itself didn't leak, since the leak never occur when i remove the line</p>
  
  <pre><code>textLabel1.text = [tmpDict objectForKey:@"name"];
  </code></pre>
  
  <p>any idea/workaround how to get rid of this problem?</p>
  
  <p>note: i do have </p>
  
  <pre><code>for (id theKey in listOfInfo) {
     [[listOfInfo objectForKey:theKey]  release];
  }
  [listOfInfo release];
  </code></pre>
  
  <p>on dealloc already</p>