Creating an NSDate every time this method executes results in a pretty big spike in memory whenever a bunch of notifications come in at once. Use NSTimeIntervals instead for this.
authorPeter Hosey <hg@boredzo.org>
Sun May 23 02:14:30 2010 -0700 (2010-05-23)
changeset 4617697f666f8b4a
parent 4616 e4ef457f5531
child 4618 04cd118c896e
Creating an NSDate every time this method executes results in a pretty big spike in memory whenever a bunch of notifications come in at once. Use NSTimeIntervals instead for this.
Core/Source/GrowlLog.h
Core/Source/GrowlLog.m
     1.1 --- a/Core/Source/GrowlLog.h	Sat Apr 24 18:24:16 2010 -0700
     1.2 +++ b/Core/Source/GrowlLog.h	Sun May 23 02:14:30 2010 -0700
     1.3 @@ -23,7 +23,8 @@
     1.4  
     1.5  @interface GrowlLog: NSObject
     1.6  {
     1.7 -	NSDate *lastLoggingEnabledFetchDate;
     1.8 +	NSTimeInterval lastLoggingEnabledFetchTime;
     1.9 +	BOOL hasFetchedLoggingEnabled;
    1.10  	BOOL loggingEnabled;
    1.11  }
    1.12  
     2.1 --- a/Core/Source/GrowlLog.m	Sat Apr 24 18:24:16 2010 -0700
     2.2 +++ b/Core/Source/GrowlLog.m	Sun May 23 02:14:30 2010 -0700
     2.3 @@ -51,19 +51,21 @@
     2.4  	return singleton;
     2.5  }
     2.6  
     2.7 -- (void) dealloc {
     2.8 -	[lastLoggingEnabledFetchDate release];
     2.9 -	[super dealloc];
    2.10 +- (id) init {
    2.11 +	if ((self = [super init])) {
    2.12 +		hasFetchedLoggingEnabled = NO;
    2.13 +	}
    2.14 +	return self;
    2.15  }
    2.16  
    2.17  - (BOOL) isLoggingEnabled {
    2.18 -	NSDate *now = [NSDate date];
    2.19 -	if (lastLoggingEnabledFetchDate && ([now timeIntervalSinceDate:lastLoggingEnabledFetchDate] < minimumLoggingEnabledFetchInterval)) {
    2.20 +	NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
    2.21 +	if (hasFetchedLoggingEnabled && ((now - lastLoggingEnabledFetchTime) < minimumLoggingEnabledFetchInterval)) {
    2.22  		//Not time yet.
    2.23  	} else {
    2.24  		loggingEnabled = [[GrowlPreferencesController sharedController] boolForKey:GrowlLoggingEnabledKey];
    2.25 -		[lastLoggingEnabledFetchDate release];
    2.26 -		lastLoggingEnabledFetchDate = [now retain];
    2.27 +		lastLoggingEnabledFetchTime = now;
    2.28 +		hasFetchedLoggingEnabled = YES;
    2.29  	}
    2.30  
    2.31  	return loggingEnabled;