On Nov 5, 2009, at 8:12 PM, Chris Purcell wrote:

        //Parse the XML
        - (void) parseXML:(NSTimer *)timer {
XMLParser *parser = [[XMLParser alloc] initWithURL:@"Location of the XML" delegate:self];
                [queue addOperation:parser];
                [parser release]; //this is where my problem is
        }

This code works, as long as I don't release the parser object after this:

        [queue addOperation:parser];
        [parser release];

However, if I don't release the Parser object, the app leaks like crazy, since it's creating new Parser objects on each fire of the timer. When I release the parser, the second fire the app terminates: "Program received signal: “EXC_BAD_ACCESS”.".

Exactly where does the EXC_BAD_ACCESS happen? On which line in your code? What's the backtrace?

Trying running with zombies enabled (NSZombieEnabled=YES). Xcode > Run > Run with Performance Tool > Zombies. That's probably the easiest way to find the problem.

At a guess, you're not retaining the queue. If you don't release parser objects, they retain the queue implicitly for you. If you do, nothing keeps the queue retained and it gets deallocated. On the second fire of the timer, you message a deallocated object.

Another possibility is that the part you left out, the actual argument that you pass to the parser's init method, is the problem. If you are passing some URL object that you expect to be persistent but which has actually be deallocated, that might also explain it.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to