Core/Source/GrowlApplication.m
author Evan Schoenberg
Mon Aug 24 00:32:47 2009 -0500 (2009-08-24)
changeset 4317 1e9e11a7092f
parent 3551 c2d0ccc3e035
child 4439 8e5827d639dc
permissions -rw-r--r--
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.
     1 //
     2 //  GrowlApplication.m
     3 //  Growl
     4 //
     5 //  Created by Evan Schoenberg on 5/10/07.
     6 //
     7 
     8 #import "GrowlApplication.h"
     9 
    10 @implementation GrowlApplication
    11 
    12 - (void)resetAutoreleasePool:(NSTimer *)timer
    13 {
    14 #pragma unused (timer)
    15 	[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
    16 										location:NSZeroPoint
    17 								   modifierFlags:0
    18 									   timestamp: (double)(AbsoluteToDuration(UpTime())) / 1000.0
    19 									windowNumber:0
    20 										 context:NULL
    21 										 subtype:0
    22 										   data1:0 
    23 										   data2:0]
    24 			 atStart:YES];
    25 }
    26 
    27 - (void)run
    28 {
    29 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    30 	[[NSTimer scheduledTimerWithTimeInterval:30
    31 									  target:self
    32 									selector:@selector(resetAutoreleasePool:)
    33 									userInfo:nil
    34 									 repeats:YES] retain];
    35 	[pool release];
    36 
    37 	[super run];
    38 }
    39 
    40 @end