Reputation: 3243
I am using a singleton for some shared stuff. In the simulator, the app crashes ocasionally. Tracking the crash down shows that the the properties of my singleton became dealocated. Those crashes never happend on a real device. Does the simulator handle memory managemend different? GC maybe?
Changed the singleton to match this pattern. The Simulator dont crash now, but I am not sure about the memory handling on the real device. I assume that this solution will cause problems.
What do you think?
Upvotes: 0
Views: 268
Reputation: 104065
You probably had the singleton wrong in the first attempt. Memory management on the Simulator works the same way as on the device, at least in principle. In practice there are some differences because of timing issues or because the Simulator has plenty memory and will not send you the memory warnings. But these differences will not affect a correctly written singleton.
The linked singleton code looks good on a skim. In my opinion you would do best to get rid of the singletons completely and wire your application using Interface Builder or dependency injection.
Upvotes: 1