Boriss Mejias wrote:
Raphael Collet wrote:
Dear Ashis,

The port only keeps a reference to the unbound tail of the stream. It does not keep alive all former messages that were sent.

Sorry for joining late, but, if you have a pointer to the beginning of the stream, then all the messages sent to that port will stay in the stream and not be garbage collected. is that right? for instance:

declare
S P
P = {NewPort S}
thread
   for Msg in S do
      {Browse Msg}
   end
end

That will keep the whole stream of messages because you can always access S.

An alternative code would be

declare
P
thread
   S
in
   P = {NewPort S}
   for Msg in S do
      {Browse Msg}
   end
end

on this second code you don't need to keep the whole stream, and then the garbage collector should be able to do its job.

cheers
Boriss

This is completely right. In the first example, S is part of the global (interactive) environment and is always accessible -> its data is never collected. In the second example, S is local and the 'for' loop traverses it -> all the data in the stream eventually becomes inaccessible and is collected. The identifier P refers to the port name and to the *current end* of the stream, so it can be global without
hurting the memory management.

Peter

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to