How does one track down an issue with a script that runs as “stay open”, yet over time the “Real Memory” grows from an initial size of about 18MB to upwards of 300MB if left running long enough?
The script is a modified version of the GrowliChat notification script:
(*
* This script requires Growl. You can download Growl here: http://growl.info
* Once you have installed Growl, you can save this script as an application,
* remember to check the "Stays Open" option before saving.
* Then double-click the new application and enjoy.
*
* Comments and ideas to arminb@mac.com
*)
property idleTime : 15
property lastList : {}
on run
delay idleTime
if my isIChatRunning() then
tell application "iChat"
activate
set lastList to id of every account where status is available
end tell
end if
return idleTime
end run
on idle
if my isIChatRunning() then
tell application "iChat"
set currentList to id of every account where status is available
end tell
repeat with x in currentList
if x is not in lastList then
my notifyWithAccountID(x)
end if
end repeat
repeat with x in lastList
if x is not in currentList then
my notifyWithAccountID(x)
end if
end repeat
set lastList to currentList
end if
return idleTime
end idle
on notifyWithAccountID(theID)
set appName to "GrowliChat"
set notificationName to "iChat Status"
set notifs to {notificationName}
tell application "iChat"
if ((first account where id is theID) exists) then
set theName to name of (first account where id is theID)
set theStatus to my stringForStatus(status of (first account where id is theID))
set theService to first word of theID
set theHandle to handler of (first account where id is theID)
set theIcon to image of (first account where id is theID)
if ((theName is not null) and (theService does not start with "Bonjour") and (theService does not start with "Rendezvous")) then
tell application "GrowlHelperApp"
register as application appName all notifications notifs default notifications notifs icon of application "iChat"
try
notify with name notificationName title theName application name appName description theHandle & return & theStatus & " (" & theService & ")" image theIcon
on error
try
notify with name notificationName title theName application name appName description theHandle & return & theStatus & " (" & theService & ")"
end try
end try
end tell
end if
end if
end tell
end notifyWithAccountID
on stringForStatus(s)
try
using terms from application "iChat"
if s is away then
return "went away"
else if s is offline then
return "went offline"
else if s is available then
return "came back"
else if s is idle then
return "is idling"
else
return "status is unknown"
end if
end using terms from
on error
return ""
end try
end stringForStatus
on isIChatRunning()
tell application "System Events"
return exists process "iChat"
end tell
end isIChatRunning
I’m not comfortable with all the in’s ad out’s of run handlers and so forth, so I’d appreciate any insight on what is wrong with the above, or if it’s just a Tiger bug.