title: Memory leak in XML Parser
body: <p>I use NSXMLParser for parsing an XML document. I have the following functions (among others):</p>
  
  <pre><code>- (void) parserDidStartDocument:(NSXMLParser *)parser {
  
      // Init tempString
      tempString = [NSMutableString string];
  
  }    
  - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
  
          // save gained data for element "date"
          if ([elementName isEqualToString:@"date"])
              [entryDict setObject:[tempString copy] forKey:kXMLDictDateKey];
  
          [tempString setString:@""];
      }
  
  
      //
      // Character Handling
      //
      - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
          [tempString appendString:[[XMLParser alloc] stripUnwantedStringChars:string]]; //Just strips tabs and linebreaks and the returns the string
      }
  </code></pre>
  
  <p>tempString is an instance variable with the following property:</p>
  
  <pre><code>@property (nonatomic, retain) NSMutableString *tempString;
  </code></pre>
  
  <p>tempString does not have to be released in dealloc as it is initiated with a convenience method, thus it is automatically assigned to an autorelease pool. I have also tried the following with an alloc, init approach, yet with the same result. So here is what I did:</p>
  
  <p>1.) Run my project with instruments, let it search for leaks right after startup, there are none.
  2.) run the XML parser once, check for leaks. There are none.
  3.) run the XML Parser again, now suddenly the line with <code>[entryDict setObject:[tempString copy] forKey:kXMLDictDateKey];</code> leaked.</p>
  
  <p>I have been looking into these memory leaks for hours now, what did I forget? If you need more code please let me know, although I think my problem is somewhere in these lines.</p>
  
  <p>Ps. My checks show that between the parser (delegate) calls the "dealloc" method gets called, thus I think the parser is really loaded two times, not just once.</p>