memory saturating with a repeat loop
Richard Gaskin
ambassador at fourthworld.com
Fri Aug 21 12:35:30 EDT 2009
Andre.Bisseret wrote:
> 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.
Could the data be moved to a single stack, perhaps using custom props
for greater efficiency? Or if not, perhaps SQLite?
> 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 ?
Off the top of my head (read "test, don't trust" <g>):
local sStackList
on ProcessStacks
-- put all of the stack file names into a list:
put AllSuchStackFiles() into sStackList
--
-- Initiate the actual processing:
ProcessNextStack
end ProcessStacks
on ProcessNextStack
-- Are we done yet?:
if sStackList is empty then
answer "All done!"
else
-- Get the next stack:
put line 1 of sStackList into tStack
delete line 1 of sStackList
-- Process it:
doWhateverYouNeedToDoToStack tStack
--
-- Now that that stack's done, run this handler again:
if "ProcessNextStack" is not in the pendingMessages then
send "ProcessNextStack" to me in 10 millisecs
end if
--
end if
end ProcessNextStack
--
Richard Gaskin
Fourth World
Revolution training and consulting: http://www.fourthworld.com
Webzine for Rev developers: http://www.revjournal.com
More information about the use-livecode
mailing list