Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

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

Thats correct, watch NSCFDate in ObjectAlloc while the program is running - it gets called all the time but the peak amount of times an object of that type exists is 1 meaning no leak.
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Memory leak
    2005-07-29 18:39:01  valiantsoul [View]

    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];
    }