Memory leaks (Was: change case script)
Memory leaks (Was: change case script)
- Subject: Memory leaks (Was: change case script)
- From: Steven Angier <email@hidden>
- Date: Mon, 05 Nov 2001 00:47:56 +1100
- Organization: Macscript.com
AppleScript has a problem with its garbage-collection scheme when dealing with
lists. The more lists your script defines, the faster it will leak memory. The
leaks are actually handles which keep growing, running-over whatever is adjacent
in memory, until your applet's partition is used up. (This is probably not an
issue under OS X.)
I think that when manipulating text item delimiters you should set values to
strings instead of a list of string. This will help to minimise the memory leaks
associated with creating AELists as AppleScript seems to manage the coercion
more cleanly (although it still leaks memory).
And by all means be a good AppleScript citizen and use a save, set, restore
approach.
Steven Angier
Macscript.com
Arthur J Knapp wrote:
>
> Date: Fri, 02 Nov 2001 16:46:32 -0800
>
> Subject: Re: change case script
>
> From: Paul Berkowitz <email@hidden>
>
>
> On 11/2/01 3:33 PM, "Arthur J Knapp" <email@hidden> wrote:
>
>
>> set text item delimiters to {""}
>
>
> I notice that you are orthodox about resetting tids to the correct
>
> single-item list, Arthur, but throughout the script you set them to strings
>
> instead (lowerC's item x, "_", rather than {lowerC's item x}, {"_"}). I
>
> know you're big on timings and speed issues. Has anyone ever tested whether
>
> doing the string to list coercion for tids (which AppleScript does for you
>
> when you leave out the list braces) say, 5000 times, makes any difference
>
> whatsoever to performance?
>
>
I have never thought about this. My assumption has always been that
>
the typical value-to-single-item-list takes up very little time, but
>
I would welcome anyone showing this not to be the case.
>
>
When I write handlers, I try to always use the save, set, and restore
>
technique for tids, because I don't like to make any assumtions about
>
what the "main" calling script is doing with the delimiters, but when
>
I post "top-level" bits of code, I'm never sure what the best way to
>
deal with the tids is.