• 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: iOS: Preventing a singleton from being deallocated when the app is in the background.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iOS: Preventing a singleton from being deallocated when the app is in the background.


  • Subject: Re: iOS: Preventing a singleton from being deallocated when the app is in the background.
  • From: Greg Parker <email@hidden>
  • Date: Thu, 20 Oct 2016 16:37:15 -0700

> On Oct 19, 2016, at 8:41 PM, Alex Zavatone <email@hidden> wrote:
>
> In that case we would find out really quickly, because this is one of the classes that starts up as soon as the app makes several server calls.  When our error happens that appears like a dealloc, the app has been running and using this class for a while and is sitting around on iOS while it is in the background.
>
> Yet we are seeing log output indicating the init method getting executed twice.

Verify that you are seeing two init logs from one process rather than one init log each from two processes. (Adding the PID to the log should resolve that, if you don't have it already.)

Verify that your singleton enforcement is thread-safe. Thread-unsafe singleton enforcement can create a second singleton if there is a race.

Log the stack trace of each init call. Perhaps one caller is bypassing your singleton enforcement somehow. (For example, you wrote singleton enforcement in +alloc but some call sites are using +allocWithZone:.)

Log the address of the object being returned by init. Perhaps there is only one object but init is being called a second time on it.

Log or crash in dealloc, if your singleton enforcement might allow the object to be deallocated and then a new one to be created.


--
Greg Parker     email@hidden <mailto:email@hidden>      Runtime Wrangler


_______________________________________________

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: iOS: Preventing a singleton from being deallocated when the app is in the background.
      • From: Alex Zavatone <email@hidden>
References: 
 >iOS: Preventing a singleton from being deallocated when the app is in the background. (From: Alex Zavatone <email@hidden>)
 >Re: iOS: Preventing a singleton from being deallocated when the app is in the background. (From: Steve Christensen <email@hidden>)
 >Re: iOS: Preventing a singleton from being deallocated when the app is in the background. (From: Alex Zavatone <email@hidden>)
 >Re: iOS: Preventing a singleton from being deallocated when the app is in the background. (From: Jens Alfke <email@hidden>)
 >Re: iOS: Preventing a singleton from being deallocated when the app is in the background. (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: Resize NSCollectionView items after resize
  • Next by Date: Re: Resize NSCollectionView items after resize
  • Previous by thread: Re: iOS: Preventing a singleton from being deallocated when the app is in the background.
  • Next by thread: Re: iOS: Preventing a singleton from being deallocated when the app is in the background.
  • Index(es):
    • Date
    • Thread