advertisement

Article:
  Animating Graphics in Cocoa, Part 1
Subject:   Memory leak
Date:   2005-07-29 18:39:01
From:   valiantsoul
Response to: Memory leak

Oops sorry I forgot to watch CFDate and yes there is a memory leak.


Here is my modified animate: with no leak:
- (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];
}