Error: cannot allocate vector of size 8 Kb

Hi there, I was fitting a model in rstan which is expected to take around 10Gb RAM, my PC has 16Gb. The model fit well but I got this error saying "cannot allocate vector of size 8 Kb" and the memory usage showed 10.6Gb in Rstudio. Do you have any idea how to fix this? If it says cannot allocate vector of size 18 Gb I would understand its memory issue. Thanks a lot.

Hi there,

It is hard to know exactly what is happening here but it sounds as if it was using your ram progressively and the next new vector was of size 8kb which it couldn't assign given it has ran out of ram and it that known to you. Typically it won't say vector of size [all your ram] because that is now how the evaluation is made.

Not sure if relevant, but when I had a similar issue, I could solve it with by increasing the java heap size:

options(java.parameters = "-Xmx16g")

Note that you have to place it at the beginning of your code, restart your session and run this line before loading packages.

Thanks a lot @GreyMerchant and @xvalda, it seems a studio issue not R? If that's the case, I will just fit the model in the terminal and do post analysis in R studio

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.