mark richardson wrote:
Hi
Thanks for your reply Peter.
What you say is exactly what I expected, however I'm still confused by
something.
If I change the sample to:
declare P in
local S in
P={NewPort S}
for X in S do {Browse X} {Browse S} end
end
Then each time I do Port.send I see one value for each new 'X' (as
expected) but S builds incrementally each time. If, as in my case, the
program is intended to run continuously won't the stream just get
bigger and bigger with no garbage collection ever being initiated?
I'm assuming here that the definition of 'S' as a local variable is
what should allow the garbage collector to 'clean up' the stream once
the local...end block finishes?
Regards
Mark
Yes, S should be a variable that is "forgotten" as soon as it's no
longer needed. Global variables in the interactive interface ('declare'
variables) are never forgotten (unless one identifier is masked by
another with the same name).
In your modified example, the for loop will keep a reference to the
whole stream through S (it prints the whole stream each time a new
element arrives) and so the stream won't be garbage collected. S is
never forgotten.
Peter
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users