Re: Search Kit memory management
Re: Search Kit memory management
- Subject: Re: Search Kit memory management
- From: Michael Thon <email@hidden>
- Date: Sun, 1 Aug 2010 08:43:05 +0200
On Jul 31, 2010, at 12:15 PM, Ken Thomases wrote:
> On Jul 31, 2010, at 2:24 AM, Michael Thon wrote:
>
>> I am indexing a large set of files using Search Kit. I find that memory usage (reported by Activity Monitor) keeps growing in my app, as it indexes more documents. I don't find any memory leaks. In Instruments, I find that there can sometimes be hundreds of SKDocumentRef objects marked as living, though I would expect that I should only have one of those objects retained at a time. I guess there is something basic about memory management that I don't understand. Can anyone see something wrong with this code?
>
> You appear to be managing memory correctly in that code snippet. The autorelease pool code which you've commented out would probably be good to uncomment, but I gather doesn't fix the memory growth you're seeing.
>
> Note that although you have released your reference to the document object, you have passed it to SKIndexAddDocument(). That may retain the document object. If you configure the Object Allocations instrument to have it record reference counts, you can see exactly which code has retained the object and which has released it. On the other hand, if SKIndexAddDocument() is retaining it, that's a) an implementation detail about which you shouldn't much care, and b) beyond your control.
>
> So, you may have to either limit the number of files you're indexing or switching to another technology other than Search Kit. I don't know what kind of directory you're enumerating, but one possible way to reduce the files is to make sure you don't enumerate the contents of packages (like application bundles). Since users don't normally see the contents of those, in most cases it doesn't make sense to have searches return results from within them. Depends on your needs, of course.
>
> Regards,
> Ken
>
Hi Ken - Thanks for the info. 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.
Best
Mike
_______________________________________________
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