title: Error in serialize(data, node$con) : error writing to connection
body: <p>I'm currently trying to run some code that implements parallel processing, but I'm running into this error: </p>
  
  <pre><code>Error: cannot allocate vector of size 2.1 Gb
  Execution halted
  Error in serialize(data, node$con) : error writing to connection
  Calls: %dopar% ... postNode -&gt; sendData -&gt; sendData.SOCKnode -&gt; serialize
  Execution halted
  Warning message:
  system call failed: Cannot allocate memory 
  Error in unserialize(node$con) : error reading from connection
  Calls: &lt;Anonymous&gt; ... doTryCatch -&gt; recvData -&gt; recvData.SOCKnode -&gt; 
  unserialize Execution halted
  </code></pre>
  
  <p>I can't seem to figure out why there's a memory problem. If I take the code out of the foreach loop or change the foreach to a for loop, it works perfectly fine, so I don't think it has to do with the contents of the code itself, but rather something about the parallelization. Also, it seems to throw the error pretty soon after the code starts executing. Any ideas why this might be happening? Here's a look at my code: </p>
  
  <pre><code>list_storer &lt;- list() 
  
  list_storer &lt;- foreach(bt=2:bootreps, .combine=list, .multicombine=TRUE) %dopar% {
  ur &lt;- sample.int(nrow(dailydatyr),nrow(dailydatyr),replace=TRUE)
  ddyr_boot &lt;- dailydatyr[ur,]
  weightvar &lt;- ddyr_boot[,c('ymd1_IssueD','MatD_ymd2')]
  weightvar &lt;- abs(weightvar)
  x &lt;- DM[ur,]
  y&lt;-log(ddyr_boot$dirtyprice2/ddyr_boot$dirtyprice1)
  weightings &lt;- rep(1,nrow(ddyr_boot))
  weightings &lt;- weightings/(ddyr_boot$datenum2-ddyr_boot$datenum1)
  
  treg &lt;- repeatsales(y,x,maxdailyreturn,weightings,weightvar)
  
  
  zbtcol &lt;- 0
  cnst &lt;- NULL
  
  
  if (is.null(dums) == FALSE){
    zbtcol &lt;- length(treg)-ncol(x)
    cnst &lt;- paste("tbs(",dums,")_",(middleyr),sep="")
    if (is.null(interactVar) == FALSE){ 
      ninteract &lt;- (length(treg)-ncol(x)-length(dums))/length(dums)
      interact &lt;- unlist(lapply(cnst,function(xla) paste(xla,"*c",c(1:ninteract),sep="")))
      cnst &lt;- c(cnst,interact)}
    }     
  }       
  
  tregtotal &lt;- tregtotal + (is.na(treg)==FALSE)
  treg[is.na(treg)==TRUE] &lt;- 0
  
  list_storer[[length(list_storer)+1]] &lt;- treg
  
  }
  
  stopImplicitCluster(cl)
  </code></pre>