Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data, using refreshObject:mergeChanges: to trim a portion of my object graph and regain memory...



Hi list!

I have a calendar application that uses core data.
I have a background application (a "helper" in the modern OS X world) that is able to fire alarms when the user set an alarm on any of its events or todo, ala iCal.


Once my main app crash or quit, the helper reads the sqlite store, get all the todos or events and create alarms if they have alarms information. I you already worked with calendaring applications you know that you may work with a VERY large data set because of recurrences...

So because (for reasons i'll not explain here) my helper fetch all the events and todos, generate all their occurences if any i eventually get tens thousands of object. Once the alarms are generated (on the fly in a memory store), i would like to trim the biggest part of my graph object by turning every thing into a fault...

As the doc explain, I should use - (void)refreshObject: (NSManagedObject *)object mergeChanges:(BOOL)flag.

I've GDB this code:

NSSet* todoMOCObjects = [[todoManager managedObjectContext] registeredObjects];
NSEnumerator* todoMOCObjectsEnum = [todoMOCObjects objectEnumerator];
NSManagedObject* mobject;
while(mobject = [todoMOCObjectsEnum nextObject])
{
[[mobject managedObjectContext] refreshObject:mobject mergeChanges:NO]; // should release memory!
}


Once objects have been refreshed, EVERY objects in todoMOCObjects is a fault (isFault returns YES, when isFault was NO before the refreshObject:mergeChanges:)

So everything should work.

But using top, Activity Monitor "Real Memory" column i can see that this has no effect at all!
commenting this code produce the EXACT same amount of memory to be consumed...


anything i did wrong?
any explanation?
something I overlooked?

Thanks for your help

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.