Re: SIGBUS/SIGSEGV error problems
Re: SIGBUS/SIGSEGV error problems
- Subject: Re: SIGBUS/SIGSEGV error problems
- From: Stephane Le Cornec <email@hidden>
- Date: Tue, 12 Aug 2003 10:02:21 -0400
You aren't releasing the object you created. Think pointers.
Unrelated to your problem: you could use NSEnumerator to iterate.
At 21:18 -0400 2003/08/11, Mike Brinkman wrote:
I can't figure out why this method is causing my application to crash:
- (void)updateSum
{
int i; // counter
float sum; // sum of NSNumbers
XObject *myObject;
sum = 0;
for (i = 0; i < [myArray count]; i++)
{
myObject = [[XObject alloc] init];
myObject = [myArray objectAtIndex:i];
// increment sum with floatValue of current object's amount
sum += [[myObject amount] floatValue];
// release myObject
[myObject release];
}
[sumField setFloatValue:sum];
}
All this method is supposed to do is sum the values from an NSNumber object
in an NSMuatableArray, and place the value in a field. XObject is a subclass
of NSObject. XObject releases all of its objects in its dealloc method and
calls [super dealloc].
updateSum gets called when I add another object to myArray. It works fine
with the [myObject release] method commented out, but I get a signal 10
(SIGBUS) error if it's there and I try to add another object to myArray. If
I try [myObject autorelease] I get a signal 11 (SIGSEGV) error.
Does myObject need to be released since it's a local instance of XObject?
I'm trying to be really careful about memory leaks.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
--
Stephane!
email@hidden (Stephane Le Cornec)
+------------------- Made with recycled electrons. --------------------+
| #include <disclaimer.h> Kebekkujin desu. |
+---------<
http://www.starfiredesign.com/starfire/index.html>----------+
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.