IPhone CGRect Memory Load
On an iPhone .. Why is code like this causing a memory leak? after 2 minutes, the net bytes have doubled. All I do is move the ball around the screen with the NSTimer calling the method below.
Any ideas?
- (void)nextFrame:(NSNotification *)notification {
ballInstance.frame = CGRectMake(value, 0, 320, 480);
}
here is the "complete" code, new project, still behaves the same. It moves the jpg around the screen, and since it really consumes memory massively. If I remove "++" from "value" that's ok. (there are static graphics in other words) So ... is the image a cached question? If so, how can I stop it from reaching astronomical proportions?
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window makeKeyAndVisible];
NSTimer * nSTimer =[NSTimer scheduledTimerWithTimeInterval: .02
target: self
selector: @selector(tick)
userInfo: nil
repeats: YES];
value =0;
}
- (void)tick {
NSLog(@"tick");
myOutlet1.frame = CGRectMake(value++, 0, 320, 480);
}
source to share
This is a bug in iPhone OS 3.0. The
allocator for the graphics system reports realloc events as malloc events, so ObjectAlloc counts this as new objects that are almost never freed. I won't tell you why you might not see it when you add the Leaks tool, but
no tool would show a real leak for this.
Although I still don't know how to fix this.
source to share
I have posted a complete sample application that more or less matches your "new project" example above. Can you take a look at this and see if they give you any ideas? I ran it on a simulator and on a device with no leak.
http://static.fatmixx.com/MemTestApp.zip
It actually looks like there is no leak here. I am building against iPhoneOS 3.1 - Debugging.
Sujal
source to share