Re: Class gets EXC_BAD_ACCESS only as NSOperation
Re: Class gets EXC_BAD_ACCESS only as NSOperation
- Subject: Re: Class gets EXC_BAD_ACCESS only as NSOperation
- From: James Maxwell <email@hidden>
- Date: Tue, 24 Mar 2009 10:11:44 -0700
Scratch that last reply... Just some stupid errors.
Putting the arrays on the heap did the trick! Thanks, folks.
cheers,
J.
On 24-Mar-09, at 9:49 AM, James Maxwell wrote:
Ah, thanks. That makes sense, and it seems to be correct - I am
processing ***lots*** of data.
I just tried making the float arrays into instance variables,
wrapped in NSData objects, and it still crashes, only a little later
than before.
What's the best way of getting these arrays off the stack? I've got
several thousand of them to get through!
thanks for your help.
J.
On 24-Mar-09, at 9:04 AM, Bill Bumgarner wrote:
On Mar 24, 2009, at 8:22 AM, James Maxwell wrote:
int sliceCount = [pitchSlices count];
float midiEventsToHTM[sliceCount][20];
float rhythmEventsToHTM[sliceCount][20];
....
The rhythmEventsToHTM array is the one that's getting the bad
access error, and I can NSLog the rhythmSlices NSArray without
issue. The other thing that seems very weird is that, if I just
run the midiEventsToHTM data (i.e., commenting out anything to do
with "rhythm") it runs fine in ... the NSOperation thread.
How big is sliceCount?
Threads typically have pretty darned small stack limits. The two
float arrays above are both allocated on the stack. Thus, you are
reserving (sliceCount * 20 * sizeof(float) * 2) bytes worth of
space on the stack.
That the crash goes away when you only run w/one array and that the
crash happens always on accessing the second array for the first
time in the loop indicates that this is quite likely the case.
In general, creating really large buffers on the stack is risky.
Move the arrays to the heap and the problem will quite likely be
fixed.
b.bum
_______________________________________________
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
_______________________________________________
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