| Sign In/My Account | View Cart |
| Article: |
Animating Graphics in Cocoa, Part 1 | |
| Subject: | Memory leak | |
| Date: | 2003-03-26 18:05:02 | |
| From: | anonymous2 | |
|
This example contains a memory leak. Each iteration of the animation creates a new NSDate object that is never released. Something like this is requires:
|
||
Showing messages 1 through 3 of 3.
- (void)animate:(id)anObject
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDate *date = nil;
while (YES)
{
[self stepAnimation:nil];
[self setNeedsDisplay:YES];
if (date != nil)
[date release];
date = [NSDate dateWithTimeIntervalSinceNow:0.04];
[NSThread sleepUntilDate:date];
}
[pool release];
[NSThread exit];
}