memory saturating with a repeat loop

Jim Ault jimaultwins at yahoo.com
Fri Aug 21 14:44:11 EDT 2009


>
> But after a lot of unsuccessful trials I am completely lost and seem  
> unable to think correctly anymore!
>
> including "wait 2 milliseconds" in the repeat loop does not help.
>
> I don"t see how I could avoid the repeat loop ? (how to use a "send  
> in time" structure ? is it instead of the repeat loop ??)
> I tried to proceed one hundred stacks at a time only, but here again  
> I don"t see how to avoid a repeat loop ?
>
> What am I missing ?


Question 1:
   Is this an app or a set of stacks running in the IDE?
Question 2:
   Are you the only one using this setup?

I am assuming you are in the IDE (development environ) since your are  
saving data to substacks.

This should work in any case, compiled app or IDE
One approach is to setup the following:

--in each substack, make it self-documenting
on closestack
    set the itemdell to "/"
    get the effective filename of main stack
    get item 1 to -2 of it & "/"
    set the default folder to IT  -- the directory the stack is in

    --or use a folder to hold all the text files
    set the default folder to ("textDataFiles/" & IT)

    --because the defaultfolder is set,
    --      all the files will be stored in this directory

    get "fldname1 fldname2 fldname3 fldname4"
    get IT & "fldname5 fldname6 fldname7 fldname8"
    put it into fieldSequence
    put the short name of this stack & cr into outputBlock
    repeat for each NM in fieldSequence
       put NM & comma & fld NM & cr after outputBlock
       -- now each line has a "name, value"


    end repeat
    delete char 1 of outputBlock
    put the short name of this stack into FN
    put char 1 to -2 of outputBlock into url ("file:" & FN & ".txt")
    --because the defaultfolder is set,
    --      the file will be stored in that directory
end closestack


Now your main routine can just read in the text files that have all  
the matching data you need.
No need to open the substacks to get data, just read in the text file.

on processAllDataFromTextFiles

    set the defaulfolder to "directory/where/substacks/saved/their/ 
files/"
    put the files into fileListing
    filter fileListing with "*.txt"  -- eschew invisible files or  
stacks or zips
    repeat for each line FN in fileListing
       put url ("file:" & FN) into currentSubStackDataBlock
       --do bunches of good stuff with these numbers and labels
       -- use filter
       -- use chunking such as offset, wordOffset, itemOffset,  
lineOffset
       --reuse currSubStackDataBlock, which conserves memory

    end repeat

end processAllDataFromTextFiles

This should run fast enough for you and much better than crashing   
before completion.

Hope this helps,

Jim Ault
Las Vegas

On Aug 21, 2009, at 9:19 AM, Andre.Bisseret wrote:

> Bonjour,
>
> I have an app including about five  hundred stacks (main stacks with  
> substacks); they are physician's clients files.
> In order to produce statistics I have a handler which search the  
> values of several measures in the main stack and one substack of  
> each clients.
>
> I am using a repeat loop to search the stacks (useful to say that,  
> as soon as the values are picked up, I "delete" the main stack).
>
> Despite this, my app systematically crashes before completing the  
> all set of stacks.
>
> In the archives of the list, I found the following :
> ---------------------------------------
> Re: Releasing Memory and Virtual Memory
>
> J. Landman Gay
> Tue, 11 Aug 2009 15:27:28 -0700
>
> BNig wrote:
>
>    Derek,
>    do you import the 100 or so images in a repeat loop?
>    If so try whether adding a wait 2 milliseconds in the repeat loop  
> helps.
>    Or alternatively try to do it in a "send" structure. In my  
> experience Rev
>    has problems releasing memory in a repeat loop. When I changed to  
> a "send to
>    me in 2 milliseconds" no more problem with memory build-up.
>
> I agree, and I'm pretty sure this must be what's wrong. Rev doesn't  
> do any garbage collection until a handler ends. The most reliable  
> way is the "send in <time>" structure.
> --
> Jacqueline Landman Gay         |     jac... at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> -----------------------------------------
>
> But after a lot of unsuccessful trials I am completely lost and seem  
> unable to think correctly anymore!
>
> including "wait 2 milliseconds" in the repeat loop does not help.
>
> I don"t see how I could avoid the repeat loop ? (how to use a "send  
> in time" structure ? is it instead of the repeat loop ??)
> I tried to proceed one hundred stacks at a time only, but here again  
> I don"t see how to avoid a repeat loop ?
>
> What am I missing ?
>
> Thanks a lot in advance for any advice
>
> Best regards from Grenoble
> André
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

Jim Ault
jimaultwins at yahoo.com






More information about the use-livecode mailing list