I have been having a long term issue with my app's memory increasing, so today have stripped my code back to basics but still have the same problem.
My retain counts remain constnact (2 for each MyImage[i] and 3 for "self"]. There are no memory leaks detected by Intruments, but it does report that the memory keeps increasing.
Can anyone point out anything I am not doing right? This issue has brought my development to a halt and I've not made any real progress for about three weeks as a result.
Does the memory increase every time the loop fires, or only when creating new TestViews?
Where do you declare the array MyImage[] ? I think you're walking all over memory that you did not allocate. That's a very big deal.
Also, [MyImage[50] release] does not release all of the images - it only releases the one at index 50. That's one problem, if you're repeatedly creating and removing "TestView" objects. Better to release each imageView right after you add it as a subview.
You could also replace your "switch" statement with "NextImage = counter" , but that's not a memory problem.
Thanks for the response. Yeap the memory increases with every loop. Do I need to release after every image? When does dealloc get called? I thought it was when the app exits.
Thanks for the response. Yeap the memory increases with every loop.
The net bytes, or the overall bytes? overall bytes is fine, net bytes (and a climbing blue graph at the top) is a problem.
Quote:
Do I need to release after every image? When does dealloc get called?
Dealloc is called by the system when the object's retainCount becomes zero. This should happen when you release the testView and you remove it from the superview.
If this view is only used once for the lifetime of your program then this probably isn't the issue, but you should release all of the images in the dealloc. You could use a loop.
MyImage declaration looks fine. I don't see the purpose of these lines, though:
You are not using MyImage as a property, and I doubt you're creating dynamic methods for it.
I really don't see anything in gameLoop that should cause a memory increase. If you sort the objectAlloc display by "Net #" , can you tell what kind of object is climbing up the chart?
Recap for the lurkers: you're seeing a bunch of generalblock-0 's when you set the position of a view; this post suggests it may be a bug in Instruments, not a bug in Quartz: