Re: Search Kit memory management
Re: Search Kit memory management
- Subject: Re: Search Kit memory management
- From: Ken Thomases <email@hidden>
- Date: Sun, 1 Aug 2010 08:12:26 -0500
On Aug 1, 2010, at 1:43 AM, Michael Thon wrote:
> I am indexing possibly tens of thousands of documents. No matter what I tried, I could not get search kit to release its memory, even after closing the index. The only way I could prevent memory usage from growing too much is to do the indexing in a separate thread and shut down the thread. I have 'solved' the problem by indexing documents batch-wise, every 1000 or so in a separate thread using an NSOperation.
That doesn't make much sense. In general, "shutting down" a thread doesn't release objects. There is the relatively rarely used feature known as thread-local storage, implemented in Cocoa as -[NSThread threadDictionary], which is released when the thread exits. I'd be fairly surprised if Search Kit was using that for much.
So, if exiting out of a thread releases a significant number of objects, that's probably more due to simply exiting out of each stack frame of the thread in an orderly fashion, cleaning up as you go. For example, releasing autorelease pools.
I would also point out that using an NSOperationQueue, if that's what you're currently using to run your NSOperation, does not give you any guarantees about thread lifetimes. So, you may not actually know that threads are being terminated.
I reiterate my suggestion to use the Object Allocations instrument, configured to record reference counts, to investigate. Even if you investigate your current solution, it will illuminate why and when the objects are released, which can help you understand why it seems to fix the issue and lead to a better fix.
Regards,
Ken
_______________________________________________
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