Stack Switching Question

Dave Cragg dcragg at lacscentre.co.uk
Wed Oct 5 16:50:00 EDT 2005


On 5 Oct 2005, at 21:04, Richard Gaskin wrote:

> J. Landman Gay wrote:
>
>> Richard Gaskin wrote:
>>
>>> I used the file name form to illustrate another difference  
>>> between HC and Rev:  while you would indeed need to open a stack  
>>> in HC in order to get stuff out of it, in Rev you can get  
>>> property values of objects in unopened stacks.  When you do that  
>>> the engine reads the file into memory to access what's being  
>>> requested; if the stack has been accessed before it'll stay in  
>>> memory (unless you turn on the stack's destroyStack property), so  
>>> subsequent accesses will be lightning fast.
>>>
>> Just an addendum: Actually, I've been using this technique on  
>> multiple stacks, and found that once accessed, the stack stays  
>> open until you explicitly close it regardless of its destroystack  
>> settings. I found this out after I accessed data from a ton of  
>> external stacks and then discovered them all open later on. I had  
>> to specifically close them to remove them from RAM (their  
>> destroystack was true, so that did the trick.) If an accessed  
>> stack has its destroystack set to false, just closing it won't be  
>> enough, the script will have to delete it as well. (I know you  
>> already know that, Richard, just mentioning it for completeness.)
>>
>
>
> Actually I didn't know that. Is that a bug?  It rather invalidates  
> the destroyStack property, no?
>

I think we could debate that one for a month or two. :-)

I suppose the destroyStack is intended to apply when a stack is  
closed, and therefore has been explicitly opened earlier. Referencing  
an external stack isn't the same as opening it.

Like Jacque, I've been caught out with stacks in memory when I'd long  
forgotten about. However, one practical problem for the engine to  
overcome would be to determine when it should purge the stack.  
Typically, when I reference an external stack, I'm likely to make a  
few references to it within a handler. Having to reload the stack for  
each reference could introduce an overhead. (Perhaps referenced  
stacks should be purged when any currently running handlers finish.)

Meanwhile, I try to remember to specifically delete each externally  
referenced stack.

Cheers
Dave



More information about the use-livecode mailing list