Search code examples
rwinbugsjagsr-coda

Memory exhausted trying to extract from big mcmc.list


I have problem trying to extract a single variable from big mcmc.list:

> x <- outRJ$mcmc[,'avail_int']
Error: cannot allocate vector of size 146.8 Mb

The outRJ$mcmc mcmc.list is big, 442 MB actually (contains data for 3 chains for like 960 variables, each 20000 iterations):

> object.size(outRJ$mcmc)/1024/1024
[1] 442.5508 #

But the single variable should have like 234 kB only! But the extraction of it seems to require much much more memory!

How can I extract from a big mcmc.list without requiring too much memory?


Solution

  • The current subsetting code (in the function [.mcmc.list) is making a copy of each element of the list before subsetting it. I have modified the code in the development version of coda. In the meantime, Matt's workaround should do because it also avoids the redundant copy.