Garbage collection (crashing on Windows)
bonnmike at gmail.com
Thu Aug 18 11:01:04 EDT 2016
Or you can probably delete the whole variable directly.
On Thu, Aug 18, 2016 at 8:59 AM, Mike Bonner <bonnmike at gmail.com> wrote:
> If you switch to using an array key with your global variable, and then "
> delete global gArray[yourkey]" it should release the memory.
> On Thu, Aug 18, 2016 at 8:28 AM, Ben Rubinstein <benr_mc at cogapp.com>
>> Thanks Monte, Richard.
>> As it happens this script isn't doing with properties, which is good (or
>> bad since that potentially easy fix isn't available to me!) but that's a
>> useful tip to remember. I've already moved some very large functions to
>> passing by reference.
>> The real problem is that the script was written originally 13 years ago,
>> and the basic architecture was to load everything into large global arrays
>> for cleanliness. Over that period, the size of the data has multiplied over
>> the years by 1-2 orders of magnitude; and meanwhile the processing has been
>> modified and warped almost continuously, so it's a really complicated rats
>> nest. The whole project is reaching its sunset, so the client isn't keen to
>> invest in major refactoring... but just at this point we seem to be
>> regularly hitting this limit.
>> My two biggest problems are:
>> - LC just in effect crashes/halts, rather than throwing an error so the
>> app could at least report the problem
>> - as far as I can tell, when I empty globals etc the memory isn't being
>> recovered. This is really the root of my problem.
>> On 18/08/2016 00:26, Monte Goulding wrote:
>>> There are certainly a number of tricks you can use to reduce the memory
>>> usage of your app. One interesting one I learnt recently after an internal
>>> discussion was because LiveCode copies values that have multiple reference
>>> when they are mutated and custom properties are arrays linked to the object
>>> you can save some memory by doing the following:
>>> put the myProp of me into tVar
>>> set the myProp of me to empty — here we are dereferencing the value so
>>> LiveCode doesn’t do a deep copy
>>> MutateVar tVar
>>> set the myProp of me to tVar
>>> Obviously there’s also passing by reference etc to reduce copies.
>>> The other thing you want to look at doing here is processing data in
>>> chunks rather than reading it all in.
>>> On 18 Aug 2016, at 3:52 AM, Ben Rubinstein <benr_mc at cogapp.com> wrote:
>>>> Please refresh my memory: is there any way to cause/allow garbage to be
>>>> collected without ending all script running?
>>>> I have an app which process large amounts of data. It runs fine on Mac,
>>>> but on Windows intermittently (but not frequently as the application data
>>>> source, which fluctuates, is gradually increasing) as the total memory in
>>>> use approaches 2GB, the app faults.
>>>> Obviously this is very distressing for me and my client, because the
>>>> app has lost control at this point and can't even tell us what's happening
>>>> (it normally runs on a schedule on a VM, so it often takes days to discover
>>>> that the system downstream hasn't been updated for a while, and trace back
>>>> to find that the LC app is halted).
>>>> I have managed to reduce the incidence of this by breaking the
>>>> processing into two parts, but this is undesirable for various reasons, and
>>>> only palliative. What I really want is a way for my main function to invoke
>>>> garbage collection after calling some of the larger processing steps.
>>>> Is there any way to do this? Am I right in thinking that the issue is
>>>> related to LC's total memory usage reaching 2GB on Windows? Are there any
>>>> useful functions (e.g. the "hasMemory" function is documented as "only
>>>> partially implemented, and may not return useful values on some platforms",
>>>> which makes it seem pretty pointless...)?
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
More information about the Use-livecode