Hello, I'm quite new in Iphone development. I have an app which needs to redraw quite often.
Everything is working fine expect that every time I call setNeedsDisplay, for an unknown reason it allocates memory ( I found out that using the object alloc tool) so after a couple of minutes my app crashes because of too much allocated memory.
it seems weird to me cause games need to be updated quite often so there is probably a way around this problem.
Thank you for your time
You're probably going to have to post code for us to see what you're doing wrong. It sounds like you must be creating some objects during the course of updating your screen with drawRect, and not destroying them when done?
__________________
ChronoSoft - Rogue Touch Available now in the App Store! ... Version 1.5 available now!
Everything is working fine expect that every time I call setNeedsDisplay, for an unknown reason it allocates memory ( I found out that using the object alloc tool) so after a couple of minutes my app crashes because of too much allocated memory.
Sort the ObjectAlloc instrument by "net #" and try to see what type of object is climbing up the list. That's the object that is getting created but not released. You can "drill down" into that object in the instrument, and if you use the details pane you can find what line of code creates those objects.
I don't see any object creation in the snippet you posted.
As smasher cites, it does not really look like you are doing any object creations in the drawRect routine. However, this does not bar from the SDK itself creating objects.
I'll ask the obvious question. Are you actually sure that the drawRect routine is the problem routine? And if so, how have you validated it?
There are also a few other things you could do to check as well which would be to change your value of 51 to a lower number temporarily like 10 or less and see what effect that has.
I am not an Obj-C guy, all our stuff is in C++ ('cept where necessary) ... but I'll also throw out the question of isn't CGPointMake dynamically creating memory? That could be your problem spot!?
Hey guys thanks for your help
It seems that it's Quartzcore whick allocs memory all the time.
And it is probably related I have a memory leak when I do that :
Hey guys thanks for your help
It seems that it's Quartzcore whick allocs memory all the time.
And it is probably related I have a memory leak when I do that :
Yes, you should release Nameview, and make sure that it eventually gets removed from the superview when you're done with it.
Don't worry about CGPointMake - CGPoint is a struct and gets allocated on the stack, not the heap. You're not using malloc or alloc, so there's nothing to free, release, or dealloc there.