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