• 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: Storing bundle loaded main class instances in NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Storing bundle loaded main class instances in NSArray


  • Subject: Re: Storing bundle loaded main class instances in NSArray
  • From: Daniel Luis dos Santos <email@hidden>
  • Date: Wed, 8 Apr 2009 15:34:40 +0100

Since I am using an auto release pool that is created before anything else, those initializers create auto released objects that will only be released at the end of the code execution. They will be valid until the program terminates



On Apr 8, 2009, at 3:01 PM, Steve Christensen wrote:

If your _instances variable is initialized using either [NSMutableArray array] or [NSMutableArray arrayWithCapacity:...], it will be autoreleased and become invalid. You can fix that by doing something like [NSMutableArray array] retain] or using [NSMutableArray alloc] initWithCapacity:...].

When an object is released, the underlying memory is reclaimed but any variables that were referencing the object are unmodified so they now point to garbage.

And as for zombies, Google is your friend. The first hit for NSZombieEnabled gives a good description.


On Apr 8, 2009, at 6:15 AM, Daniel Luis dos Santos wrote:

The _instances mutable array is instantiated in the default init method that is called on all other init methods. It is never released. I am using an Auto release pool. The log writes ;

2009-04-08 13:56:53.189 TestRunner[2568:813] *** -[NSFileManager fileExistsAtPath:]: unrecognized selector sent to instance 0x1126f0

When releasing a pointer does its value change ? or it just releases the memory ?
What is that zombie thing you're talking about ?



On Apr 8, 2009, at 1:53 PM, Graham Cox wrote:


On 08/04/2009, at 10:33 PM, Daniel Luis dos Santos wrote:

if ((nil != saID) && ([[saID class] isSubclassOfClass: [NSData class]])) {
//[_instances addObject: aDriverInstance];


When I uncomment the addObject line above, later in the code NSFileManager throws a doesNotRespondToSelector exception, which is very odd.



Still not enough to go on.

Where is _instances initialised? Is it released anywhere? What does the exception log? Is it possible _instances could be being released leaving a stale pointer that points to NSFileManager? Have you run it with NSZombieEnabled turned on? Any difference?

Please post the *relevant* code.

--Graham


_______________________________________________

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: Storing bundle loaded main class instances in NSArray
      • From: glenn andreas <email@hidden>
References: 
 >Fwd: Storing bundle loaded main class instances in NSArray (From: Daniel Luis dos Santos <email@hidden>)
 >Re: Storing bundle loaded main class instances in NSArray (From: Graham Cox <email@hidden>)
 >Re: Storing bundle loaded main class instances in NSArray (From: Daniel Luis dos Santos <email@hidden>)
 >Re: Storing bundle loaded main class instances in NSArray (From: Steve Christensen <email@hidden>)

  • Prev by Date: Re: Difference between SEL and const char* when sending a message?
  • Next by Date: Setting Min, MAx and range of characters for NSTextField
  • Previous by thread: Re: Storing bundle loaded main class instances in NSArray
  • Next by thread: Re: Storing bundle loaded main class instances in NSArray
  • Index(es):
    • Date
    • Thread