• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how to make a task less cpu intensive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to make a task less cpu intensive


  • Subject: Re: how to make a task less cpu intensive
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 28 Dec 2012 10:36:02 -0800

On Dec 28, 2012, at 9:40 AM, Nick Rogers <email@hidden> 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 (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


References: 
 >how to make a task less cpu intensive (From: Nick Rogers <email@hidden>)

  • Prev by Date: how to make a task less cpu intensive
  • Next by Date: Re: how to make a task less cpu intensive
  • Previous by thread: how to make a task less cpu intensive
  • Next by thread: Re: how to make a task less cpu intensive
  • Index(es):
    • Date
    • Thread