Am Do.,08.10.2009 um 16:36 schrieb Michael Süssner:

Hi ,

thanks a lot for your tips. after having read the bible and some experiments I have learned how to do it correctly.

Here the conclusion for the rest of the world:
NSMutableArray *vPolyArray = [[NSMutableArray alloc] initWithCapacity:6];
        
vPolygon = [[[PolygonShape alloc] initWithNumberOfSides:5 minimumNumberOfSides:2 maximumNumberOfSides:8] autorelease]; [vPolyArray addObject:vPolygon]; // now only the Array is the owner of the object
        
...
Hopefully the … contains no exception, no return and no break (if you are in a loop).
        
[vPolyArray autorelease]; // since I have created the array with alloc and init I have to release it or autorelease it

Thanks a lot
g
Michael




On Oct 7, 2009, at 2:53 PM, Michael Süssner wrote:
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:

You can enable zombies, which will mark deallocated objects' memory with what they used to be, and can also prevent anything from being actually deallocated ever, but is a useful way to investigate this kind of problem (if you can reach the problem before you run out of memory :) )

See NSDebug.h in Foundation.framework for some info on this.

The code is rather simple:
        NSArray *vPolyArray = [NSArray arrayWithObjects: ... ];
        [vPolyArray release];

You're over-releasing vPolyArray. +arrayWithObjects: returns an autoreleased instance, and you're also releasing it explicitly, so by the time NSAutoreleasePool gets around to releasing it, it's already gone.








_______________________________________________

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/negm-awad%40cocoading.de

This email sent to negm-a...@cocoading.de

Amin Negm-Awad
negm-a...@cocoading.de




_______________________________________________

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