Leaks with Core-Data while fetching data
Leaks with Core-Data while fetching data
- Subject: Leaks with Core-Data while fetching data
- From: "Hell's KItchen Hell's KItchen" <email@hidden>
- Date: Sun, 6 May 2007 13:06:11 +0200
Hello,
I'm working on a program that takes articles from the net and store
the relative index into a Core-Data persistent store. Unfortunatly
using OmniObjectMeter I've found a leak (it consumes lots of memory
resources) in a function that search into the database for a
particular message and returns it.
This function is called lots of time when the program downloads
messages (it uses this function in order to link a messages with
another).
The code is here:
- (ANTArtNode *)articleNodeForID:(NSString *) _id {
NSExpression *right = [NSExpression expressionForConstantValue: _id];
NSPredicate *pr = [NSComparisonPredicate
predicateWithLeftExpression: keypathmsgid rightExpression: right
modifier: NSDirectPredicateModifier type:
NSEqualToPredicateOperatorType options:
NSCaseInsensitivePredicateOption];
[request setPredicate: pr];
NSError *error;
NSArray *array = [[self managedObjectContext]
executeFetchRequest:request error:&error];
if (array != nil) {
return [array lastObject];
} else {
NSLog(@"Error occurred in query: %@", [error description]);
return nil;
}
}
I've created both NSFetchRequest and NSExpression (left) into the
class (initialized at init) in order to reduce the memory usage. I've
also used NSComparisonPredicate instead of using NSPredicate
predicateWithFormat method. But nothing has changed (or it's changed
but the change is very small). This a screenshot of omniobjectmeter
(there are two other functions that do a similar things listed above
this).
(I've unsuccessfully tried to add an autorelease pool. Omniobject
meter says the the line is NSArray *array = [[self
managedObjectContext] executeFetchRequest:request error:&error]; ....
but array is an autorelease object, right? and really it contains
always one message because the id is unique):
http://img2.freeimagehosting.net/image.php?ff553648af.png
Anyone can help me?
Thanks a lot.
Have a nice day.
Michael
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden