Memory leaks when running an apple event
Memory leaks when running an apple event
- Subject: Memory leaks when running an apple event
- From: Alex Bumbu <email@hidden>
- Date: Fri, 12 Oct 2007 18:13:39 +0300
Hi all,
I'm trying to create an simple application using Apple Events to see if
a specified application is running (iTunes in my case). A thread from
main.m will use the mainProcess method so the script will run every
second. The problem I'm having is that the NSAppleEventDescriptor i'm
using (result) isn't deallocated and the every 100 secs it grows with
1Mb of memory. Can someone help me please ... I've tried release,
dealloc, autorelease and isn't working. Please if you know give me some
ideas how to solve this problem in cocoa. Thanx guys.
This is the code I'm using:
-(void)isAppRunning
{
NSString* appleEventString = [NSString stringWithFormat:@"set
itunes_active to false\n with timeout of 1 second\n tell application
\"Finder\"\n if (get name of every process) contains \"iTunes\" then set
itunes_active to true\n end tell\n end timeout\n return itunes_active"];
NSAppleScript *script = [[NSAppleScript alloc]
initWithSource:appleEventString];
NSDictionary *errorInfo;
NSAppleEventDescriptor* result;
result = [script executeAndReturnError:errorInfo];
NSLog(@"%@", [result stringValue]);
[result dealloc];
[script dealloc];
}
-(void)mainProcess:(id)anObject
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
while (1)
{
[self isAppRunning];
}
[pool release];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden