Search Results

Search found 2 results on 1 pages for 'jluckyiv'.

Page 1/1 | 1 

  • Looking for advice on importing large dataset in sqlite and Cocoa/Objective-C

    - by jluckyiv
    I have a fairly large hierarchical dataset I'm importing. The total size of the database after import is about 270MB in sqlite. My current method works, but I know I'm hogging memory as I do it. For instance, if I run with Zombies, my system freezes up (although it will execute just fine if I don't use that Instrument). I was hoping for some algorithm advice. I have three hierarchical tables comprising about 400,000 records. The highest level has about 30 records, the next has about 20,000, the last has the balance. Right now, I'm using nested for loops to import. I know I'm creating an unreasonably large object graph, but I'm also looking to serialize to JSON or XML because I want to break up the records into downloadable chunks for the end user to import a la carte. I have the code written to do the serialization, but I'm wondering if I can serialize the object graph if I only have pieces in memory. Here's pseudocode showing the basic process for sqlite import. I left out the unnecessary detail. [database open]; [database beginTransaction]; NSArray *firstLevels = [[FirstLevel fetchFromURL:url retain]; for (FirstLevel *firstLevel in firstLevels) { [firstLevel save]; int id1 = [firstLevel primaryKey]; NSArray *secondLevels = [[SecondLevel fetchFromURL:url] retain]; for (SecondLevel *secondLevel in secondLevels) { [secondLevel saveWithForeignKey:id1]; int id2 = [secondLevel primaryKey]; NSArray *thirdLevels = [[ThirdLevel fetchFromURL:url] retain]; for (ThirdLevel *thirdLevel in thirdLevels) { [thirdLevel saveWithForeignKey:id2]; } [database commit]; [database beginTransaction]; [thirdLevels release]; } [secondLevels release]; } [database commit]; [database release]; [firstLevels release];

    Read the article

  • Leak in NSScanner category method

    - by jluckyiv
    I created an NSScanner category method that shows a leak in instruments. - (BOOL)scanBetweenPrefix:(NSString *)prefix andSuffix:(NSString *)suffix intoString:(NSString **)value { NSCharacterSet *charactersToBeSkipped = [self charactersToBeSkipped]; [self setCharactersToBeSkipped:nil]; BOOL result = NO; // find the prefix; the scanString method below fails if you don't do this if (![self scanUpToString:prefix intoString:nil]) { MY_LOG(@"Prefix %@ is missing.", prefix); return result; } //scan the prefix and discard [self scanString:prefix intoString:nil]; // scan the important part and save it if ([self scanUpToString:suffix intoString:value]) // this line leaks { result = YES; } [self setCharactersToBeSkipped:charactersToBeSkipped]; return result; } I figure it's the way I'm passing the value to/from the method, but I'm not sure. It's a small leak (32 bytes), but I'd like to do this right if I can. Thanks in advance.

    Read the article

1