Re: NSArrayController - Remove and immediately deallocate objects
Re: NSArrayController - Remove and immediately deallocate objects
- Subject: Re: NSArrayController - Remove and immediately deallocate objects
- From: Jerry Krinock <email@hidden>
- Date: Sat, 01 Feb 2014 11:30:58 -0800
On 2014 Feb 01, at 10:50, Leonardo <email@hidden> wrote:
> The objects get properly removed but they don't get deallocated immediately.
This is not an issue with the array controller. It is an issue with memory management in general.
First of all, I presume that you have a good reason (such as that the objects are using huge memory that you want to free up) for requiring that these objects be deallocated immediately. Otherwise, you shouldn’t be worried about them because forcing objects to dealloc can be tedious and difficult.
The problem is that something else other than the array controller controller has retained your boxes.
> NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
> NSArray *boxes = [mBoxesArrayController arrangedObjects];
> [mBoxesArrayController removeObjects:boxes];
> [pool release];
Scratch that. In order for a local autorelease pool to be effective, it must enclose the target objects’ entire life cycle, beginning with their creation. You’ve missed their creation.
> I have been looking for a solution and found something like
>
> [managedObjectContext processPendingChanges];
That might help, if indeed the objects have been deleted from the managed object context. At some point, you might need to verify that.
> But I can't get the managedObjectContext for that NSArrayCOntroller that I have created on IB.
To access objects instantiated in nibs, use an outlet.
* * *
Getting back to the tedious and difficult, you need to track everything that might ever have retained your boxes from their creation. Since your boxes are apparently “managed” (Core Data) objects, read this…
https://developer.apple.com/library/ios/documentation/cocoa/conceptual/CoreData/Articles/cdMemory.html
One thing for sure is that, if this managed object context has an Undo Manager, deleted objects are being retained in case there is an Undo or Redo.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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