Why "Objects are only deleted on idle"?

Mark Waddingham mark at livecode.com
Wed Sep 23 13:17:10 EDT 2015


On 2015-09-23 18:44, Richard Gaskin wrote:
> I'm having a hard time conceiving of a circumstance in which it's
> necessary o build a large number of objects only to delete them again
> in the same handler.
> 
> What am I missing?

Any loop of the form:

repeat ...
    create stack / object
    do something with created object / stack
    delete stack / object
end repeat

Would previously cause memory to increase as the engine would only free 
the memory used by the objects when it returned to the root event loop. 
Now it knows it can free the memory at the point of the delete if the 
object was created at the same level, or in a call made within the loop.

Now, obviously this kind of thing could always be refactored to use 
'send in time' - however that means you have to refactor all handlers 
which call such a handler to also work in that fashion (not necessarily 
a trivial transformation).

It has been a long standing problem which exists because of the way the 
engine currently handles objects internally (more specifically how it 
has a tendency to retain direct pointers to objects on the C stack). We 
finally worked out a reasonable solution to the problem which didn't 
involve reworking a substantial amount of code :)

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list