LC Garbage Collection?

Dar Scott Consulting dsc at swcp.com
Tue Sep 24 19:44:27 EDT 2019


Yeah, "GUI recursion" is a little obtuse.

I'm referring to a style of using wait with messages inside an event handler so that other events (especially keyboard and mouse) can be handled. Sometimes this is done to allow a "background" task. It is easy to do this in a way that makes a mess of things. One scenario is loading a large file at the start of a mouseUp and then use lots of wait with messages sprinkled throughout, but the task somehow gets started several times and memory usage is a problem.

Of course one can be very careful and consider what problems might happen, so this is not a hard and fast admonition. The use of busy flags can help.

I do this occasionally when experimenting with move, but I move away immediately.

And I do like the idea of writing a "background" the way one thinks of it and sprinkling in some waits, but as soon as things expand (you want to do two things in the background), then this falls apart. 

I encourage embracing event programming.

> On Sep 24, 2019, at 2:43 PM, Tom Glod via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> HH...yup I know...... Dar, thanks for those hints and tidbits, I'll be
> putting those right into my pocket as i optimize code going forward.
> 
> I have pretty good cleanup habits, so  I am getting good results with how
> it is (in 9.05) ..... but sometimes its scary.  It like the GC happens only
> when things are idle and quiet....maybe there is a threshold.
> 
> When you say GUI recursion....do you mean,,,,if i draw interfaces using
> functions that call themselves?
> 
> On Tue, Sep 24, 2019 at 3:40 PM Dar Scott Consulting via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> 
>> I don't know where you will find details. (Maybe if we keep this
>> conversation going, we will get a response in a half day.)
>> 
>> I believe it is reference-counting with lazy cleanup for high-level
>> objects, but with carefully crafted destructors for low level objects.
>> Because of the lazy cleanup, it is sometimes hard to see when memory
>> problems occur or to infer GC behavior
>> 
>> But, to me it doesn't matter. I like the memory management of LiveCode. It
>> cleans up. It doesn't have astonishingly-long pauses that I remember. It
>> would be nice to know that cleanup is not delayed forever, though, and for
>> that I am not sure. I have only run into memory problems with some ML
>> projects, so my experience might not shed much light.
>> 
>> Sources of memory leaks are LC, LC scripts, OS, libraries, LCB and (I
>> suppose) compilers. I don't think we can assume the problem is not in the
>> user script. I have seen script memory leaks like these:
>> 1. Leaving large data in script locals
>> 2. Indefinite log variables
>> 3. Poor range checking in recursive functions
>> 4. mouseUp recursion*
>> 5. Queue/stack bugs
>> 6. Bad parsing
>> 
>> *GUI recursion is a root of all kinds of evil. If tempted, leave your
>> cloak and run.
>> 
>> Dar Scott
>> Mad Scientist
>> 
>>> On Sep 24, 2019, at 12:36 PM, Tom Glod via use-livecode <
>> use-livecode at lists.runrev.com> wrote:
>>> 
>>> Hi folks, I'm wondering if anyone can help me to understand Livecode's
>>> garbage collection.  I am developing an application that is intended to
>>> stay in memory and so I must watch memory consumption carefully. I've had
>>> some instances where memory ran way out of control.... but I found a
>> couple
>>> of reasons for that...... one of them being the dozen or so memory leaks
>>> that were fixed in 9.05.
>>> 
>>> When I build the standalone in 9.04 its a disaster. When I build with
>> 9.05
>>> I am very impressed with my application clearing its own memory..... even
>>> to the point where it consumes less than what it does when the standalone
>>> first starts up
>>> 
>>> But it seems arbitrary.  Where can I go to find out more details about
>> the
>>> engine's GC?
>>> 
>>> Thanks,
>>> 
>>> Tom Glod
>>> Founder & Developer
>>> MakeShyft R.D.A (www.makeshyft.com)
>>> Office:226-706-9339
>>> Mobile:226-706-9793
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> 
> -- 
> Tom Glod
> Founder & Developer
> MakeShyft R.D.A (www.makeshyft.com)
> Office:226-706-9339
> Mobile:226-706-9793
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list