On Dec 28, 2012, at 9:40 AM, Nick Rogers <roger...@mac.com> wrote:

> I have a tree in memory (all nodes malloc'ed blocks) and when I start freeing 
> this large tree, I traverse the tree and free all nodes.
> This becomes cpu intensive and so the progress bar on my sheet doesn't 
> animate.
> 
> In similar other situations the progress bar animates, when different code is 
> executed in the background.

You’re freeing the tree on a background thread, and the UI thread is locking 
up? That shouldn’t happen.

My first answer to any sort of performance or why-does-this-thread-block 
question is “sample it”. Use Instruments or Activity Monitor or the ‘sample’ 
tool to see what’s going on inside while in this state. It’s possible that the 
freeing is happening on the main thread by mistake, or the freeing code is 
holding some lock that the main thread gets stuck waiting for.

You must have a vast number of tree nodes, if freeing the tree takes a 
macroscopic amount of time. Are they all the same size? If so, you can use a 
custom allocator for them (as long as they’re C structs or C++ objects); 
that’ll be much faster than malloc.

—Jens
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to