I have read through this SO question and answers (R parallel computing and zombie processes) but it doesn't seem to quite address my situation.
I have a 4-core MacBook Pro running Mac OS X 10.10.3, R 3.2.0, and RStudio 0.99.441.
Yesterday, I was trying out the packages "foreach" and "doParallel" (I want to use them in a package I am working on). I did this:
cl <- makeCluster(14)
registerDoParallel(cl)
a <- 0
ls <- foreach(icount(100)) %dopar% {
b <- a + 1
}
It is clear to me that it doesn't make sense to have 14 processes on my 4-core machine, but the software will actually be run on a 16-core machine. At this point my computer ground to a halt. I opened activity monitor and found 16 (or more, maybe?) R processes. I tried to force quit them from the activity monitor -- no luck. I closed RStudio and that killed all the R processes. I reopened RStudio and that restarted all the R processes. I restarted the computer and restarted RStudio and that restarted all the R processes.
How can I start RStudio without restarting all those processes?
EDIT: I forgot to mention that I also rebuilt the package I was working on at the time (all the processes may have been running during the build)
EDIT2: Also, I can't StopCluster(cl) because cl is not in the environment anymore...I closed that R session.
EDIT3: When I open R.app (The R GUI provided with R) or open R in the terminal, no such problem occurs. So I think it must be RStudio-related.
EDIT4: There appears to be a random delay between opening RStudio and the starting of all these undesired processes. Between 15s and 2 mins.
EDIT5: It seems the processes only start after I open the project from which they were started.
EDIT6: I have been picking through the .Rproj.user files looking for things to delete. I deleted all the files (but not the directories) in ctx, pcs, and sdb. Problem persists.
EDIT7: When I run "killall R" at the command line it kills all these processes, but when I restart RStudio and reopen the project, all the processes start again.
EDIT8: I used "killall -s R | wc -l" to find that the number of R processes grows and grows while the project is open. It got up to 358 and then I ran "killall R" because my computer was making scary sounds.
EDIT9: RStudio is completely unusable currently. Every time I "killall R", it restarts all the processes within 15 seconds.
EDIT10: When I initiate a build that also starts up tons of R processes -- 109 at last check. These processes all get started up when the build says "preparing package for lazy loading". At this point the computer grinds to a near-halt.
EDIT11: I deleted the .Rproj file (actually just moved it as a backup) and the .Rproj.user directory. I used "create project from directory" in RStudio. When I open that NEW project, I still get the same behavior. What is RStudio doing when I open a project that isn't contained anywhere in the .Rproj file or the .Rproj.user directory!? I've spent the whole day on this one problem....:(