Every 30 seconds, post an Other event to trigger clearing of the autorelease pool; otherwise, we'll amass unreleased objects when the system is idle. This replaces a cycling NSAutoreleasePool system which solved the same problem but which posed problems in some future timelines.
authorEvan Schoenberg
Mon Aug 24 00:32:47 2009 -0500 (2009-08-24)
changeset 43171e9e11a7092f
parent 4316 6b6757af79e9
child 4318 1d5a5e793f09
Every 30 seconds, post an Other event to trigger clearing of the autorelease pool; otherwise, we'll amass unreleased objects when the system is idle. This replaces a cycling NSAutoreleasePool system which solved the same problem but which posed problems in some future timelines.
Core/Source/GrowlApplication.m
     1.1 --- a/Core/Source/GrowlApplication.m	Thu Aug 20 19:50:54 2009 -0500
     1.2 +++ b/Core/Source/GrowlApplication.m	Mon Aug 24 00:32:47 2009 -0500
     1.3 @@ -8,24 +8,33 @@
     1.4  #import "GrowlApplication.h"
     1.5  
     1.6  @implementation GrowlApplication
     1.7 -static NSAutoreleasePool *globalPool = nil;
     1.8 +
     1.9  - (void)resetAutoreleasePool:(NSTimer *)timer
    1.10  {
    1.11  #pragma unused (timer)
    1.12 -	[globalPool release];
    1.13 -	globalPool = [[NSAutoreleasePool alloc] init];
    1.14 +	[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
    1.15 +										location:NSZeroPoint
    1.16 +								   modifierFlags:0
    1.17 +									   timestamp: (double)(AbsoluteToDuration(UpTime())) / 1000.0
    1.18 +									windowNumber:0
    1.19 +										 context:NULL
    1.20 +										 subtype:0
    1.21 +										   data1:0 
    1.22 +										   data2:0]
    1.23 +			 atStart:YES];
    1.24  }
    1.25  
    1.26  - (void)run
    1.27  {
    1.28 -	globalPool = [[NSAutoreleasePool alloc] init];
    1.29 +	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    1.30  	[[NSTimer scheduledTimerWithTimeInterval:30
    1.31  									  target:self
    1.32  									selector:@selector(resetAutoreleasePool:)
    1.33  									userInfo:nil
    1.34  									 repeats:YES] retain];
    1.35 +	[pool release];
    1.36 +
    1.37  	[super run];
    1.38 -	[globalPool release]; globalPool = nil;
    1.39  }
    1.40  
    1.41  @end