SeikoTheWiz
SeikoTheWiz

Reputation: 883

NSOperationQueue and Memory

I've been using an NSOperationQueue and I have very strange memory issue with it. I've tried reducing the issue to the simplest possible probleme and here I got:

in init:

_queue = [[NSOperationQueue alloc] init];

Later:

TestOperation op = [[TestOperation alloc] init];
[self.queue addOperation: op];

then in the method called by the main of the operation:

NSLog(@"I'm right here!");

If I call this thousands of times, my memory used just keep growing.

I've I only remove the NSLog from my method (thus calling an empty method) my memory don't change.

What am I doing wrong here??

Upvotes: 3

Views: 794

Answers (1)

aichamorro
aichamorro

Reputation: 71

When you add an operation to an NSOperationQueue, the operation queue owns the object and will be responsible of releasing it. Perhaps you are not giving enough time to the NSOperationQueue to release the memory and see the results?

For this cases you can surrounded it with an @autorelease block, but since the operation queue is the one responsible for the release of the objects I don't know if it will work. Is worth a try.

Upvotes: 1

Related Questions