On a background thread checking for intersections I was leaking a large amount of memory. I tracked down where the leak was occurring and it was due to fast enumeration. I tried using an @autorelease but that did not fix it either. What ended up fixing the leak was just using normal iteration, and I have no idea why.
background thread created using dispatch_async, running on ipad mini 2 ios8
// shapes is a NSMutable array
for (RTShape *shape in shapes){
// ... intersection code
}
results in a memory leak, with this fixing it
for (int i = 0; i < shapes.count; i++){
RTShape *shape = [shapes objectAtIndex: i];
// ... same intersection code
}
Does anyone know why this causes a leak?