title: memory leak when decoding a NSArray with NSKeyedUnarchiver decodeObjectForKey
body: <p>I'm trying to fix a huge memory leak that is caused somewhere in a method, that gets a NSData object from a CoreData datastore and unarchives that NSData back into a NSArray.</p>
  
  <pre><code>- (CustomObject *) getCustomObject
  {
  .... get myManagedObject from CoreData Store
  
      CustomObject *customObject = nil;
      if(myManagedObject)
      {
          customObject = [[[CustomObject alloc] init] autorelease];
  
          NSData *arrayData = [myManagedObject valueForKey:@"resultArray"];
  
          /* read and save resultArray */
          NSKeyedUnarchiver *unArchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:arrayData];
  
          /* per definition decodeObjectForKey returns an autoreleased object */
          /* Instruments (The Profiler) points out this line for the source */
          /* of the memory leak. */
          NSArray *myArray = [unArchiver decodeObjectForKey:@"rArray"];
  
          /* myArray is a (nonatomic,retain) property in CustomObject */
          [customObject setMyArray:myArray];
  
          /* finishDecoding and release unarchiver */
          [unArchiver finishDecoding];
          [unArchiver release];
      }
  
      return customObject;
  }
  </code></pre>
  
  <p>If i release myArray (what i should not do, since it is a autoreleased object) the memory leak disappears.</p>
  
  <p>Does anyone know how you can solve this issue? The items in the NSArray of the CustomObject are NSDictionary objects.</p>
  
  <p>thanks in advance</p>
  
  <p>edit: - (CustomObject *) getCustomObject is called very often, so the impact of this leak is quite big.</p>