You might want to enclose the inner loop with an @autoreleasepool { ... }
which tells the compiler when to do the disposal, otherwise the pool will only be emptied when control returns to the main loop.
for (i = 0; i < 10; i++) {
@autoreleasepool {
...
}
}
As pointed out by CodeFi in the comments:
This will create a new autoreleasepool for each iteration of the loop, which would destroy each object after the iteration is completed, but would make the program do more work. If you don't mind all the objects hanging around until after the loop is completed, you would put the @autoreleasepool
outside of the outer loop
@autoreleasepool {
for (i = 0; i < 10; i++) {
...
}
}