On Aug 1, 2010, at 2:43 AM, Michael Thon wrote: > > 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.
Hi Mike, What happens if you periodically call SKIndexFlush() in your loop? After closing the index, did you use Instruments to confirm that your allocated memory is still allocated or did you look at memory usage in Activity Monitor? Due to underlying memory management, Activity Monitor may not be useful for this kind of analysis. Aaron _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com