Skip to content
Prev 1535 / 2152 Next

mclapply: rm intermediate objects and returning memory

Hi Simon,

First, thanks for the detailed explanations. Comments/questions below.
On Mon, 15 Oct 2012 12:17:20 -0400,Simon Urbanek <simon.urbanek at r-project.org> wrote:
Aha, OK, I think I understand now. I was expecting all of the memory
(except that associated with the object being explicitly returned) to have
been freed at that point (right after the function returns). So the
problem lied on my expectations ;-).
I just rerun the example above, using only gc() without explicitly
removing the x, and it does work fine.
Thanks for the suggestion. I'll play around with local. I actually run
into this as part of a different problem, on a machine with a lot more RAM
(256 GB) and many more cores (64), where several large temporary objects
are created inside each function. 

If I understand correctly, though, using x <- local() would not provide
any advantage compared to explicitly removing the objects and calling
gc(). Is this correct?
Actually, I am rather happy with the two options (in fact, most of the
time I only use preschedule = TRUE); it was just that I was not really
understanding memory usage. ;-).


Thanks again for your detailed explanation.


R.