title: Running out of memory in this CoreData (Objective C) code segment
body: <p>I wrote this method to test a CoreData backing store. While running the test method,
  I am running out of memory. I have 100 elements in the inner loop and 10
  records in the outer loop. I am testing this on an iPad (actual device).</p>
  
  <pre><code>-(void) uploadTestHubData: (NSInteger) hubs entriesPerHub: (NSInteger) elems
  {
      CoreDataWrapper *cdw = [CoreDataWrapper getInstance:@"/Documents/journaldata0.sqlite"];
  [self loadTestImages];
  
  for (int i = 0; i &lt; hubs; i++) {
      NSLog(@"Uploading hub - %d", i);
  
      Hub *newhub = [NSEntityDescription insertNewObjectForEntityForName:@"Hub" inManagedObjectContext:cdw.context];
      newhub.Title = @"Changed ... Hub Title";
      newhub.Last_Update = [NSDate date];
      newhub.Create_Date = [NSDate date];
      newhub.Type = [NSNumber numberWithInt:0];
      newhub.Description = @"This is a test hub. I am just testing the hub structure.";
  
      for (int j = 0; j &lt; elems; j++) {
          HubBasicElement *helem = [NSEntityDescription insertNewObjectForEntityForName:@"HubBasicElement" inManagedObjectContext:cdw.context];
          helem.CoverArt = UIImagePNGRepresentation([self getRandomImage]);
          helem.Create_Date = [NSDate date];
          helem.Title = @"Title of Clipped Page";
          helem.ElementType = [NSNumber numberWithInt:0];
          helem.Source_URL = @"Some web URL";
          [newhub addChildrenObject:helem];
          [cdw commitCoreData];
      }
  }       
  NSLog(@"Finished uploading the test data ....");
  }
  </code></pre>