A short side note.
I looked into "The Joy of Clojure" and there is a nice diagram on page 251 about the difference if you use send and send-off to send actions to an agent. The intersting on send is, that the agent queues the send actions if you use send. If you use send-off the agent does not stores the action into a queue.

Could be, that in the case of pmap a similiar effect takes place and the agent has less actions which does not need to be stored in his queue. This can be the reason for the lesser memory consuption.

And yes on page 248 in "The Joy of Clojure" there is written:
"Agents are integrated with STM transactions, <...>".

If I understand this correct, then Agents are under the "control" of the STM or at least are influenced by the STM.

Am 03.04.2012 18:48, schrieb Jim - FooBar();:
Hmmm....interesting thoughts...

I was under the impression that that agents are asynchronous and thus do not depend on the STM , which is only for co-ordinated change! There is a dedicated Thread pool where agents are assigned separate threads for their work.You seem to suggest otherwise...I guess i 'll have to resort to my Clojure books...perhaps we could post a new question with different title here on the group...I'm sure more experienced people can answer that with not much time spent...

Bottom line is that unless i use pmap i run the risk of running out of memory...presumably it's the same for you.

Jim


On 03/04/12 17:16, Marcus Lindner wrote:
Maybe the reason is the STM.
If I rmember it correctly, then agents and refs are controlled by Clojures STM mechanic. Eventuelly the us of map increase the work for the STM and so it needs more time to schedule all the agent calls and this result in a higher memory usage.

When you use pmap the calls are working in parallel and the STM might have less agents calls to schedule and this might reduce the stress.

On the otherside, the work the agents have do to is not so hard and the STM might shine in comparison to pmap or other parallel calls if there is much more work to do.

But these are only guesses...


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to