Why "Objects are only deleted on idle"?
ambassador at fourthworld.com
Wed Sep 23 13:27:34 EDT 2015
Mark Waddingham wrote:
> 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 :)
The "how" was pretty clear from the Release Notes. I just couldn't
figure out the "why". How often to people create objects they don't want?
For ID preservation I tend to do what the DG does, hiding rather than
disposing of controls I'm likely to need again.
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the Use-livecode