Re: Autorelease pool
Re: Autorelease pool
- Subject: Re: Autorelease pool
- From: Shawn Erickson <email@hidden>
- Date: Wed, 7 Oct 2009 15:04:52 -0700
On Wed, Oct 7, 2009 at 2:53 PM, Michael Süssner
<email@hidden>wrote:
> I habe created a small shell programm using Cocoa Foundation class for test
> purposes.
>
> After my test program has passed successfully the drain method of the
> autorelease buffer is called and "sometimes" I get the following error:
> Program received signal: “EXC_BAD_ACCESS”.
> sharedlibrary apply-load-rules all
>
>
> How can I track which object has already been release:
>
>
>
> The code is rather simple:
> void printPolygonInfo()
> {
> PolygonShape * vPolygon;
> NSString *str;
> int i;
> NSArray *vPolyArray = [NSArray arrayWithObjects:
> [[PolygonShape alloc]
> initWithNumberOfSides:4 minimumNumberOfSides:3 maximumNumberOfSides:7],
> [[PolygonShape alloc]
> initWithNumberOfSides:6 minimumNumberOfSides:5 maximumNumberOfSides:9],
> [[PolygonShape alloc]
> initWithNumberOfSides:11 minimumNumberOfSides:9 maximumNumberOfSides:12],
> nil];
>
> for (vPolygon in vPolyArray){
> NSLog(@"%@\n Retain Count:%d",[vPolygon description],
> [vPolygon retainCount]);
> }
>
> NSLog(@"Try to set number of sides equal 10\n\n");
> for (vPolygon in vPolyArray){
> vPolygon.numberOfSides = 10;
> }
> [vPolyArray release];
>
> }
>
> When I delete the NSLog line, then the code seems to run fine. Even the
> retaincount is 2, so??
>
> Any suggestions?
What does your implementation -[PolygonShape description] look like?
Also you are leaking all of the PolygonShape instance you allocate and add
to the vPolyArray array. Review the memory management rules.
-Shawn
_______________________________________________
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