• 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: ARC Retain Cycles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC Retain Cycles


  • Subject: Re: ARC Retain Cycles
  • From: Jim McGowan <email@hidden>
  • Date: Sat, 26 Apr 2014 15:27:40 +0800

On 25 April, 2014 5:45:24 pm HKT,  Dave <email@hidden> wrote:

> It’s not dogma! autorealease meant my App peaked at 150MB, whereas it needed 10 MB! Autorelease caused 140 MB of data to be useless held in memory for the duration of the Thread for no good reason.
>

‘Autorelease’ wasn’t causing your app to use 150mb, it was your loop that was causing the memory usage.  If you have a loop where each iteration is going to create/fetch/copy a significant amount of data, then it is pretty standard practice to have an autorelease pool inside the loop, as otherwise you are depending on the next pool in the chain, which is probably the main thread’s pool which is only popped once per event loop interation.

> You can’t avoid autorelease, you need to do some work to undo it ASAP to stop the memory building up too much. In this case the solution is to copy the data into new objects and then drain the pool. Works a treat - you can’t avoid it BUT you can undo it!


I don’t really understand what you mean by “undo it”, but I the thing to remember is that autorelease pools are not like garbage collection, you have to be responsible for them in your own code in the same way that you are responsible for balancing new/init/copy/retain with release.

Jim



_______________________________________________

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


  • Follow-Ups:
    • Re: ARC Retain Cycles
      • From: Dave <email@hidden>
  • Prev by Date: Re: GCD killed my performance
  • Next by Date: Re: NSToolbarItem Action Not Passed to NSButton...
  • Previous by thread: Re: ARC Retain Cycles
  • Next by thread: Re: ARC Retain Cycles
  • Index(es):
    • Date
    • Thread