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

_______________________________________________

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

Reply via email to