beginer question: multiple do the same procedure in file
[1/2] from: sags::apollo::lv at: 3-Aug-2004 22:31
What will happens with memory resources when
the same file will be called with do:
f.ex.
forever [
do %fileWithProcsAndFuncs.r
]
brgds
Janeks
[2/2] from: moliad:aei:ca at: 4-Aug-2004 1:22
this depends on the actuall content of the file.
in rebol, there is automatic garbage collection... so if the file is only
defining words like in the following:
;------------------------------------
a: [a block of data]
b: "a simple string"
c: func [arg] [print arg]
;----------------------------------
everytime the file is 'DOne it will assign the new block, string and func to
words which already exist. the data which was assigned to those words before ,
being unreferenced, will be added to the garbage heap.
The memory should cleanup by itself, everytime it hits the threshold... which I
have found to be something flexible, depending on what kind of data is
collected.
the following is an example of file content which will cause ram to fill up:
;---------------------------------------------------
either value? 'blk [
append/only blk ["a string"]
][
blk: []
]
probe blk
;----------------------------------------------
what happens here is that the same word is being reused so that blk is always
being grown at each evaluation of the script... because you are actually adding
data to a word which stays defined, no garbage collection is obviously possible,
cause the data is referenced at least once... within blk...
HTH
-MAx