title: ARC memory issue with SQLitePersistence class
body: <p>I can't be able to figure out why does app crashes, while inserting the data into a database by using <code>SQLitePersistence</code> class.</p>
  
  <p>After downloaded the product xml data from webservice, I'm trying to insert all the product details into the various table like,</p>
  
  <pre><code>Product 
  Product_image
  Product_option
  Product_categories
  Product_custom_option
  </code></pre>
  
  <p>As for now, we have 800 products available on the webservice, in future it may increase about 2000 product.</p>
  
  <p><strong>My problem is</strong> : after inserting 400 to 450 products, app crashes regularly. Then I use <code>@autorelesepool</code> for each and every loop of inserting the data to database. It increases 500 to 550 products then app crashes, what can I do next to avoid app crashes?</p>
  
  <p>My <code>SQLitePersistence</code> database class for Product table <code>.h</code> file:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import "SQLitePersistentObject.h"
  
  @interface iMobDB : SQLitePersistentObject
  {
      NSString *sku;
      NSString *name;
      .....
      .....
  }
  @property(nonatomic,retain) NSString *sku;
  @property(nonatomic,retain) NSString *name;
  .....
  .....
  @end
  </code></pre>
  
  <p><code>.m</code> file</p>
  
  <pre><code>@implementation iMobDB
  
  @synthesize sku;
  @synthesize name;
      .....
      .....
  
  -(void) dealloc
  {
      for (NSString *one in [[self class] propertiesWithEncodedTypes])
      {
          [self removeObserver:self forKeyPath:one];
      }
      iMobReleaseNil(sku);
      iMobReleaseNil(name);
      .....
      .....
  }
  </code></pre>
  
  <p>Im inserting the data here in <code>Appdelegate</code> class</p>
  
  <pre><code> /*===================================== Save Product Information ===============================================*/
  
          iMobDB *imobdb = [[iMobDB alloc]init];
          imobdb.productId = [productid intValue];
          imobdb.sku = skukey;
          imobdb.name = namekey;
          imobdb.optionalOption = [NSString stringWithFormat:@"%d",options];
          imobdb.requriedOption = [NSString stringWithFormat:@"%d",requried];
          imobdb.productType = producttypekey;
          imobdb.price = pricekey;
          imobdb.specialprice = specialpricekey;
          imobdb.stock = [stock intValue];
          imobdb.manufacture = manukey;
          [imobdb save];
          imobdb=nil;
  
          /*==============================================================================================================*/
  
          /*==================================== Save Product Images =====================================================*/
         __unsafe_unretained NSDictionary  *imagearray=[[dict objectForKey:@"images"] objectForKey:@"url"];
  
          @autoreleasepool 
          {
  
          for (NSDictionary *dict in imagearray)
          {
              if ([dict  isKindOfClass:[NSArray class]])
              {
                  NSString *imageurl=[dict objectForKey:@"text"];                
                  ImageDB *imagedb = [[ImageDB alloc] init];
                  imagedb.productId = [productid intValue];
                  imagedb.imageurl = imageurl;
                  [imagedb save];
                  imagedb=nil;
              }
              else if([dict  isKindOfClass:[NSDictionary class]])
              {
                  NSString *imageurl=[dict objectForKey:@"text"];              
                  ImageDB *imagedb = [[ImageDB alloc] init];
                  imagedb.productId = [productid intValue];
                  imagedb.imageurl = imageurl;
                  [imagedb save];
                  imagedb=nil;
              }
          }
  
          }
          /*===============================================================================================================*/
  
          /*==================================== Save Category ============================================================*/
          @autoreleasepool 
          {
  
        __unsafe_unretained  NSDictionary *categorydict = [dict objectForKey:@"categories"];
  
                  for (NSDictionary *dictt in catedict)
                  {
                   __unsafe_unretained   NSString *categoryid=[[dictt objectForKey:@"categoryId"]objectForKey:@"text"];
                  __unsafe_unretained    NSString *categoryname=[[dictt objectForKey:@"categoryName"]objectForKey:@"text"];                    
                      Categories *catdb  = [[Categories alloc] init];
                      catdb.categoryId = [categoryid intValue];
                      catdb.categoryname = categoryname;
                      catdb.productId = [productid intValue];
                      [catdb save];
                      catdb=nil;
                  }
              }
  </code></pre>
  
  <p>Please note: I have disable the ARC in the following class</p>
  
  <p><img src="https://i.stack.imgur.com/OjG70.png" alt="enter image description here"></p>
  
  <p><strong>Error log Screenshot</strong></p>
  
  <p><img src="https://i.stack.imgur.com/M3MGf.png" alt="enter image description here"></p>
  
  <p><strong>Error log</strong></p>
  
  <blockquote>
    <p>Feb  1 11:53:59 Innoppl-iPod backboardd[52] : iMob[2811] has
    active assertions beyond permitted time:      {(
           identifier: Suspending process: iMob[2811] permittedBackgroundDuration: 10.000000 reason: suspend
    owner pid:52 preventSuspend  preventThrottleDownCPU 
    preventThrottleDownUI     )} Feb  1 11:53:59 Innoppl-iPod backboardd[52]
    : Forcing crash report of iMob[2811]... Feb  1 11:53:59
    Innoppl-iPod backboardd[52] : Finished crash reporting. Feb 
    1 11:53:59 Innoppl-iPod ReportCrash[2819] : libMobileGestalt
    copySystemVersionDictionaryValue: Could not lookup ReleaseType from
    system version dictionary Feb  1 11:53:59 Innoppl-iPod
    com.apple.launchd<a href="https://i.stack.imgur.com/OjG70.png" rel="nofollow noreferrer">1</a>
    (UIKitApplication:com.innoppl.Saletab[0xe1bf][2811]) :
    (UIKitApplication:com.innoppl.Saletab[0xe1bf]) Exited: Killed: 9 Feb 
    1 11:53:59 Innoppl-iPod backboardd[52] : Application
    'UIKitApplication:com.innoppl.Saletab[0xe1bf]' exited abnormally with
    signal 9: Killed: 9 Feb  1 11:53:59 Innoppl-iPod ReportCrash[2819]
    : Saved crashreport to
    /var/mobile/Library/Logs/CrashReporter/iMob_2013-02-01-115359_Innoppl-iPod.plist
    using uid: 0 gid: 0, synthetic_euid: 501 egid: 0</p>
  </blockquote>