Re: Recursion taking up far too much memory... any ideas?
Re: Recursion taking up far too much memory... any ideas?
- Subject: Re: Recursion taking up far too much memory... any ideas?
- From: Ryan Homer <email@hidden>
- Date: Wed, 6 Jun 2007 07:41:06 -0400
On 3-Jun-07, at 06/03/07 1:37 PM, Sam Stigler wrote:
The problem I'm having is that the first time I ran the program,
(1) it took forever (but Shark says this is due mainly to Cocoa API
calls that I can't get rid of unfortunately), but more importantly,
(2) it took up a whole lot of memory -- up to around 50 MB by the
time it was far less than halfway through. The heavy lifting is
being done in a separate thread with its own autorelease pool; it
looks to me like the problem is that the autorelease pools aren't
being released until the recursions (if you can call a void method
a recursion) are finished.
If you want memory released right away, you need to 'release' it at
the appropriate moment instead of using 'autorelease'. It's always
more memory efficient to manage your own memory instead of relying on
the auto cleanup... at least for now, I'm not sure what the situation
will be like with Leopard.
I think also that Core Data tries to keep as much of the database in
memory so you might want to look up ways to flush data to the
persistent store. For example, the following is from the Core Data
Programming Guide:
Change and Undo Management
Managed objects that have pending changes (insertions, deletions, or
updates) are retained by their context until their context is sent a
save:, reset , rollback, or dealloc message, or the appropriate
number of undos to undo the change.
The undo manager associated with a context retains any changed
managed objects. By default, the context's undo manager keeps an
unlimited undo/redo stack. To limit your application's memory
footprint, you should make sure that you scrub (using
removeAllActions) the context's undo stack as and when appropriate.
Unless you retain a context's undo manager, it is deallocated with
its context.
_______________________________________________
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