New Stack crash

Richard Gaskin ambassador at
Wed Jun 23 01:06:40 CDT 2010

Dan Friedman wrote:

 > I have the following script in a button:
 > on mouseUp
 >   put 0 into i
 >   repeat 30000
 >     add 1 to i
 >     put ("testStack_" & i) into sName
 >     new stack sName
 >     delete stack sName
 >   end repeat
 > end mouseUp
 > Two questions:
 > (1) Why would this start to slow down?  It starts off quite
 > fast, then it beings to slow down.  It gets so that it takes
 > 5, or 6 seconds to complete one repeat.  This happens in both
 > in REV and as a standalone.  Is this because of the "add 1 to
 > i"?  Is this no better than "repeat with i = ...", which is
 > known to be slow?
 > (2) Rev will eventually crash.  In my testing, it seems random
 > and crashes sometime after about 1700.  Shouldn't the "delete
 > stack" call completely remove the stack?  So, why crash?
 > Any thoughts?

I'd guess memory.

Rev does a lot of its garbage collection at idle, and if you watch this 
run while the Activity Monitor is active you'll see RAM usage creep up 
and eventually start crowding out physical RAM, dropping into swap.

Try adding this in your loop:

   wait 0 with messages

That seems to do the trick for a lot of loop that could benefit from a 
little idle time.

What is it you're trying to do?

You get get the same end result with less processing power with this:

on mouseUp
end mouseUp


  Richard Gaskin
  Fourth World
  Rev training and consulting:
  Webzine for Rev developers:
  revJournal blog:

More information about the use-livecode mailing list