gadget-framework / rgadget

Rgadget is a set of useful utilities for gadget
6 stars 12 forks source link

garbage collection in gadget.fit #76

Closed pfrater closed 7 years ago

pfrater commented 7 years ago

I am having problems using gadget.fit in a loop (either lapply or for loop) during, for example, fitting multiple bootstrap runs. The issue I am running into is that gadget.fit produces a number of connections when called, which can be seen with showConnections(all = T). It shouldn't be too much of a hassle to just close these with closeAllConnections() embedded at the end of each iterations, but this tends to crash R for whatever reason.

Has anyone else run into this issue? How did you deal with it? Perhaps we should consider implementing some sort of garbage collection within gadget.fit...

vbartolino commented 7 years ago

I've experienced the issue when running gadget.fit several time in a session. Luckily I was not forced to a loop so my simple approach has been to close and open a new R session.

Not sure how much useful can be for this issue, but I've reported a similar one on an early version of Rgadget when using gadget.iterative (see #42) I've been advised and able to solve the issue at that time by using closeAllConnections(), but apparently it doesn't seem to do the trick here

bthe commented 7 years ago

Could you try to use the mclapply function from multicore package, which creates a new R session for each item in the list?

pfrater commented 7 years ago

This seemed to work once I took out closeAllConnections(). Thanks

Also, on a side note. I believe multicore is now deprecated. I think it's been rolled together with snow into the parallel package.

bthe commented 7 years ago

That is true, I just confused the parallel package with multicore