# Error: cannot allocate vector of size 17348.7 Gb

**URL:** <https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615>\
**Category:** RStan\
**Created:** [April 27, 2020, 1:56am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615 "2020-04-27T01:56:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![RR\_Stan](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@RR\_Stan](https://discourse.mc-stan.org/u/RR_Stan)\
**Post date:** [April 27, 2020, 1:56am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/1 "2020-04-27T01:56:57Z")

</div>

Short summary of the problem

This is not a new issue. I read a few threads on this topic and it does not solve my issue. I am using Window 10, just installed R 4.0, Rtools4.0 and the newest version of RStudio (1.2.5042). I followed the instruction on the Stan website to install rStan and the relevant steps since yesterday, and had various errors. I tried to look up the errors and tried different suggestions, and re-installed everything with the newest version. “Error: cannot allocate vector of size 17348.7 Gb” is the newest error.

I tried to install package “Rcpp” several times and once manually removed it. I tried to removed `-march=native` and `-mtune=native`. I saw a message of updating to R 4.0, but could not remotely install the app from Github “remotes::install\_github(“r-lib/pkgbuild”)”. I never used Github before and has myself signed up today.

I have been using OpenBUGS for Bayesian analysis and wanted to try rStan. I shared the comments of a different user that rStan is more than difficult for someone who just want to use Stan to run the Bayesian model, and is not technical savvy. After two days, I could not even get rStan running.

**code\_to\_run\_your\_model(if\_applicable)**

I am just trying to the 8 schools example:

fit \<- stan(file = ‘Eight Schools.stan’, data = schools\_dat)  
Error: cannot allocate vector of size 17348.7 Gb

Thanks so much for your help! I am really confused now and “desperate” for some “magical” solution and insight!

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [April 27, 2020, 6:06am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/2 "2020-04-27T06:06:20Z")

</div>

It is finding RTools35 rather than RTools40. I would uninstall RTools35. You might also need to set the environmental variable `RTOOLS40_HOME` to wherever RTools40 is installed. If

```
Sys.setenv(RTOOLS40_HOME = "C:/rtools40") # or whatever

```

gets it to work, you can add that line to ~/.Rprofile .

---

<div class="post-metadata">

**Author:** ![RR\_Stan](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@RR\_Stan](https://discourse.mc-stan.org/u/RR_Stan)\
**Post date:** [April 27, 2020, 6:41am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/3 "2020-04-27T06:41:43Z")

</div>

Thanks for your answers.

I uninstalled RTools35 and tried to run Sys.setenv(RTOOLS40\_HOME = “C:/rtools40”) from Rstudio

and still get similar error message.

“Error: cannot allocate vector of size 16023.6 Gb”

Is it adequate to run Sys.setenv(RTOOLS40\_HOME = “C:/rtools40”) from Rstudio? I don’t know how to add this line to ~/.Rprofile (Sorry for my ignorance on this).

Also I don’t quite understand the error message – 16023.6 Gb is a huge size for a vector.

Anything else I may try?

Thank you!

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [April 27, 2020, 6:50am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/4 "2020-04-27T06:50:30Z")

</div>

Is rtools now installed in `C:/rtools40` or somewhere else?

---

<div class="post-metadata">

**Author:** ![RR\_Stan](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@RR\_Stan](https://discourse.mc-stan.org/u/RR_Stan)\
**Post date:** [April 27, 2020, 6:56am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/5 "2020-04-27T06:56:33Z")

</div>

Yes it is installed under C:\rtools40

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [April 27, 2020, 5:24pm UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/6 "2020-04-27T17:24:13Z")

</div>

What are

```
Sys.getenv("RTOOLS40_HOME")
Sys.getenv("PATH")

```

?

---

<div class="post-metadata">

**Author:** ![RR\_Stan](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@RR\_Stan](https://discourse.mc-stan.org/u/RR_Stan)\
**Post date:** [April 27, 2020, 6:26pm UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/7 "2020-04-27T18:26:47Z")

</div>

> Sys.getenv(“RTOOLS40\_HOME”)  
> [1] “C:\rtools40”  
> Sys.getenv(“PATH”)  
> [1] “C:\rtools40\usr\bin;C:\Program Files\R\R-4.0.0\bin\x64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\Dell Data Protection\Encryption\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files\SASHome\SASFoundation\9.4\ets\sasexe;C:\Program Files\SASHome\Secure\ccme4;C:\Program Files (x86)\Webex\Plugins;C:\Users\fur\AppData\Local\Microsoft\WindowsApps;”

thanks for your continued attention on this!

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [April 27, 2020, 10:28pm UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/8 "2020-04-27T22:28:38Z")

</div>

OK, that looks right. Can you post the part of the output that involves calling `g++` when you execute

```
example(stan_model, package = "rstan", run.dontrun = TRUE)

```

?

---

<div class="post-metadata">

**Author:** ![RR\_Stan](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@RR\_Stan](https://discourse.mc-stan.org/u/RR_Stan)\
**Post date:** [April 27, 2020, 11:40pm UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/9 "2020-04-27T23:40:15Z")

</div>

It has a long output for something and here is the error message:

Compilation argument:  
C:/Program Files/R/R-40~1.0/bin/x64/R CMD SHLIB file2a803b211e4f.cpp 2\> file2a803b211e4f.cpp.err.txt  
Error in file(con, “r”) : cannot open the connection  
In addition: Warning message:  
In file(con, “r”) :  
cannot open file ‘file2a803b211e4f.cpp.err.txt’: No such file or directory

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [April 27, 2020, 11:42pm UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/10 "2020-04-27T23:42:35Z")

</div>

We need the part of the long output that says something like `C:/rtools40/mingw_64/bin/g++ ...`.

---

<div class="post-metadata">

**Author:** ![RR\_Stan](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@RR\_Stan](https://discourse.mc-stan.org/u/RR_Stan)\
**Post date:** [April 27, 2020, 11:46pm UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/11 "2020-04-27T23:46:22Z")

</div>

Below is the whole thing. Rstudio prompted to install more things which I did. I also reinstalled Rtool40. Thanks!

> example(stan\_model, package = “rstan”, run.dontrun = TRUE)

stn\_md\> stancode ← ‘data {real y\_mean;} parameters {real y;} model {y ~ normal(y\_mean,1);}’

stn\_md\> mod ← stan\_model(model\_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ FROM Stan CODE TO C++ CODE NOW.  
successful in parsing the Stan model ‘73fc79f8b1915e8208c736914c86d1a1’.  
COMPILING THE C++ CODE FOR MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ NOW.  
OS: x86\_64, mingw32; rstan: 2.19.3; Rcpp: 1.0.4.6; inline: 0.3.15  
WARNING: Rtools is required to build R packages, but the version of Rtools previously installed in C:/rtools40 has been deleted.

Please download and install Rtools custom from [RTools: Toolchains for building R and R packages from source on Windows](https://cran.r-project.org/bin/windows/Rtools/).

> > setting environment variables:  
> > PKG\_LIBS = -L"C:/Users/fur/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders  
> > PKG\_CPPFLAGS = -I"C:/Users/fur/Documents/R/win-library/4.0/Rcpp/include/" -I"C:/Users/fur/Documents/R/win-library/4.0/RcppEigen/include/" -I"C:/Users/fur/Documents/R/win-library/4.0/RcppEigen/include/unsupported" -I"C:/Users/fur/Documents/R/win-library/4.0/BH/include" -I"C:/Users/fur/Documents/R/win-library/4.0/StanHeaders/include/src/" -I"C:/Users/fur/Documents/R/win-library/4.0/StanHeaders/include/" -I"C:/Users/fur/Documents/R/win-library/4.0/rstan/include" -DEIGEN\_NO\_DEBUG -D\_REENTRANT -DBOOST\_DISABLE\_ASSERTS -DBOOST\_PENDING\_INTEGER\_LOG2\_HPP -include stan/math/prim/mat/fun/Eigen.hpp -std=c++1y  
> > Program source :

1 :  
2 : // includes from the plugin  
3 : // [[Rcpp::plugins(cpp14)]]  
4 :  
5 : // user includes  
6 : #define STAN\_\_SERVICES\_\_COMMAND\_HPP#include \<boost/integer/integer\_log2.hpp\>  
7 : #include \<rstan/rstaninc.hpp\>  
8 : // Code generated by Stan version 2.19.1  
9 :  
10 : #include \<stan/model/model\_header.hpp\>  
11 :  
12 : namespace model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace {  
13 :  
14 : using std::istream;  
15 : using std::string;  
16 : using std::stringstream;  
17 : using std::vector;  
18 : using stan::io::dump;  
19 : using stan::math::lgamma;  
20 : using stan::model::prob\_grad;  
21 : using namespace stan::math;  
22 :  
23 : static int current\_statement\_begin\_\_;  
24 :  
25 : stan::io::program\_reader prog\_reader\_\_() {  
26 : stan::io::program\_reader reader;  
27 : reader.add\_event(0, 0, “start”, “model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1”);  
28 : reader.add\_event(3, 1, “end”, “model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1”);  
29 : return reader;  
30 : }  
31 :  
32 : class model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1 : public prob\_grad {  
33 : private:  
34 : double y\_mean;  
35 : public:  
36 : model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1(stan::io::var\_context& context\_\_,  
37 : std::ostream\* pstream\_\_ = 0)  
38 : : prob\_grad(0) {  
39 : ctor\_body(context\_\_, 0, pstream\_\_);  
40 : }  
41 :  
42 : model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1(stan::io::var\_context& context\_\_,  
43 : unsigned int random\_seed\_\_,  
44 : std::ostream\* pstream\_\_ = 0)  
45 : : prob\_grad(0) {  
46 : ctor\_body(context\_\_, random\_seed\_\_, pstream\_\_);  
47 : }  
48 :  
49 : void ctor\_body(stan::io::var\_context& context\_\_,  
50 : unsigned int random\_seed\_\_,  
51 : std::ostream\* pstream\_\_) {  
52 : typedef double local\_scalar\_t\_\_;  
53 :  
54 : boost::ecuyer1988 base\_rng\_\_ =  
55 : stan::services::util::create\_rng(random\_seed\_\_, 0);  
56 : (void) base\_rng\_\_; // suppress unused var warning  
57 :  
58 : current\_statement\_begin\_\_ = -1;  
59 :  
60 : static const char\* function\_\_ = “model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1”;  
61 : (void) function\_\_; // dummy to suppress unused var warning  
62 : size\_t pos\_\_;  
63 : (void) pos\_\_; // dummy to suppress unused var warning  
64 : std::vector vals\_i\_\_;  
65 : std::vector vals\_r\_\_;  
66 : local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
67 : (void) DUMMY\_VAR\_\_; // suppress unused var warning  
68 :  
69 : try {  
70 : // initialize data block variables from context\_\_  
71 : current\_statement\_begin\_\_ = 1;  
72 : context\_\_.validate\_dims(“data initialization”, “y\_mean”, “double”, context\_\_.to\_vec());  
73 : y\_mean = double(0);  
74 : vals\_r\_\_ = context\_\_.vals\_r(“y\_mean”);  
75 : pos\_\_ = 0;  
76 : y\_mean = vals\_r\_\_[pos\_\_++];  
77 :  
78 :  
79 : // initialize transformed data variables  
80 : // execute transformed data statements  
81 :  
82 : // validate transformed data  
83 :  
84 : // validate, set parameter ranges  
85 : num\_params\_r\_\_ = 0U;  
86 : param\_ranges\_i\_\_.clear();  
87 : current\_statement\_begin\_\_ = 1;  
88 : num\_params\_r\_\_ += 1;  
89 : } catch (const std::exception& e) {  
90 : stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
91 : // Next line prevents compiler griping about no return  
92 : throw std::runtime\_error(“\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG _");  
93 : }  
94 : }  
95 :  
96 : ~model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1() { }  
97 :  
98 :  
99 : void transform\_inits(const stan::io::var\_context& context\_\_,  
100 : std::vector& params\_i\_\_,  
101 : std::vector& params\_r\_\_,  
102 : std::ostream pstream\_\_) const {  
103 : typedef double local\_scalar\_t\_\_;  
104 : stan::io::writer writer\_\_(params\_r\_\_, params\_i\_\_);  
105 : size\_t pos\_\_;  
106 : (void) pos\_\_; // dummy call to supress warning  
107 : std::vector vals\_r\_\_;  
108 : std::vector vals\_i\_\_;  
109 :  
110 : current\_statement\_begin\_\_ = 1;  
111 : if (!(context\_\_.contains\_r(“y”)))  
112 : stan::lang::rethrow\_located(std::runtime\_error(std::string(“Variable y missing”)), current\_statement\_begin\_\_, prog\_reader\_\_());  
113 : vals\_r\_\_ = context\_\_.vals\_r(“y”);  
114 : pos\_\_ = 0U;  
115 : context\_\_.validate\_dims(“parameter initialization”, “y”, “double”, context\_\_.to\_vec());  
116 : double y(0);  
117 : y = vals\_r\_\_[pos\_\_++];  
118 : try {  
119 : writer\_\_.scalar\_unconstrain(y);  
120 : } catch (const std::exception& e) {  
121 : stan::lang::rethrow\_located(std::runtime\_error(std::string("Error transforming variable y: ") + e.what()), current\_statement\_begin\_\_, prog\_reader\_\_());  
122 : }  
123 :  
124 : params\_r\_\_ = writer\_\_.data\_r();  
125 : params\_i\_\_ = writer\_\_.data\_i();  
126 : }  
127 :  
128 : void transform\_inits(const stan::io::var\_context& context,  
129 : Eigen::Matrix\<double, Eigen::Dynamic, 1\>& params\_r,  
130 : std::ostream pstream\_\_) const {  
131 : std::vector params\_r\_vec;  
132 : std::vector params\_i\_vec;  
133 : transform\_inits(context, params\_i\_vec, params\_r\_vec, pstream\_\_);  
134 : params\_r.resize(params\_r\_vec.size());  
135 : for (int i = 0; i \< params\_r.size(); ++i)  
136 : params\_r(i) = params\_r\_vec[i];  
137 : }  
138 :  
139 :  
140 : template \<bool propto\_\_, bool jacobian\_\_, typename T\_\_\>  
141 : T\_\_ log\_prob(std::vector\<T\_\_\>& params\_r\_\_,  
142 : std::vector& params\_i\_\_,  
143 : std::ostream_ pstream\_\_ = 0) const {  
144 :  
145 : typedef T\_\_ local\_scalar\_t\_\_;  
146 :  
147 : local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
148 : (void) DUMMY\_VAR\_\_; // dummy to suppress unused var warning  
149 :  
150 : T\_\_ lp\_\_(0.0);  
151 : stan::math::accumulator\<T\_\_\> lp\_accum\_\_;  
152 : try {  
153 : stan::io::reader\<local\_scalar\_t\_\_\> in\_\_(params\_r\_\_, params\_i\_\_);  
154 :  
155 : // model parameters  
156 : current\_statement\_begin\_\_ = 1;  
157 : local\_scalar\_t\_\_ y;  
158 : (void) y; // dummy to suppress unused var warning  
159 : if (jacobian\_\_)  
160 : y = in\_\_.scalar\_constrain(lp\_\_);  
161 : else  
162 : y = in\_\_.scalar\_constrain();  
163 :  
164 : // model body  
165 :  
166 : current\_statement\_begin\_\_ = 1;  
167 : lp\_accum\_\_.add(normal\_log\<propto\_\_\>(y, y\_mean, 1));  
168 :  
169 : } catch (const std::exception& e) {  
170 : stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
171 : // Next line prevents compiler griping about no return  
172 : throw std::runtime\_error(”\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG _");  
173 : }  
174 :  
175 : lp\_accum\_\_.add(lp\_\_);  
176 : return lp\_accum\_\_.sum();  
177 :  
178 : } // log\_prob()  
179 :  
180 : template \<bool propto, bool jacobian, typename T\_\>  
181 : T\_ log\_prob(Eigen::Matrix\<T\_,Eigen::Dynamic,1\>& params\_r,  
182 : std::ostream pstream = 0) const {  
183 : std::vector\<T\_\> vec\_params\_r;  
184 : vec\_params\_r.reserve(params\_r.size());  
185 : for (int i = 0; i \< params\_r.size(); ++i)  
186 : vec\_params\_r.push\_back(params\_r(i));  
187 : std::vector vec\_params\_i;  
188 : return log\_prob\<propto,jacobian,T\_\>(vec\_params\_r, vec\_params\_i, pstream);  
189 : }  
190 :  
191 :  
192 : void get\_param\_names(std::vectorstd::string& names\_\_) const {  
193 : names\_\_.resize(0);  
194 : names\_\_.push\_back(“y”);  
195 : }  
196 :  
197 :  
198 : void get\_dims(std::vector\<std::vector\<size\_t\> \>& dimss\_\_) const {  
199 : dimss\_\_.resize(0);  
200 : std::vector\<size\_t\> dims\_\_;  
201 : dims\_\_.resize(0);  
202 : dimss\_\_.push\_back(dims\_\_);  
203 : }  
204 :  
205 : template   
206 : void write\_array(RNG& base\_rng\_\_,  
207 : std::vector& params\_r\_\_,  
208 : std::vector& params\_i\_\_,  
209 : std::vector& vars\_\_,  
210 : bool include\_tparams\_\_ = true,  
211 : bool include\_gqs\_\_ = true,  
212 : std::ostream pstream\_\_ = 0) const {  
213 : typedef double local\_scalar\_t\_\_;  
214 :  
215 : vars\_\_.resize(0);  
216 : stan::io::reader\<local\_scalar\_t\_\_\> in\_\_(params\_r\_\_, params\_i\_\_);  
217 : static const char_ function\_\_ = “model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::write\_array”;  
218 : (void) function\_\_; // dummy to suppress unused var warning  
219 :  
220 : // read-transform, write parameters  
221 : double y = in\_\_.scalar\_constrain();  
222 : vars\_\_.push\_back(y);  
223 :  
224 : double lp\_\_ = 0.0;  
225 : (void) lp\_\_; // dummy to suppress unused var warning  
226 : stan::math::accumulator lp\_accum\_\_;  
227 :  
228 : local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
229 : (void) DUMMY\_VAR\_\_; // suppress unused var warning  
230 :  
231 : if (!include\_tparams\_\_ && !include\_gqs\_\_) return;  
232 :  
233 : try {  
234 : if (!include\_gqs\_\_ && !include\_tparams\_\_) return;  
235 : if (!include\_gqs\_\_) return;  
236 : } catch (const std::exception& e) {  
237 : stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
238 : // Next line prevents compiler griping about no return  
239 : throw std::runtime\_error("\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG **_");  
240 : }  
241 : }  
242 :  
243 : template   
244 : void write\_array(RNG& base\_rng,  
245 : Eigen::Matrix\<double,Eigen::Dynamic,1\>& params\_r,  
246 : Eigen::Matrix\<double,Eigen::Dynamic,1\>& vars,  
247 : bool include\_tparams = true,  
248 : bool include\_gqs = true,  
249 : std::ostream_ pstream = 0) const {  
250 : std::vector params\_r\_vec(params\_r.size());  
251 : for (int i = 0; i \< params\_r.size(); ++i)  
252 : params\_r\_vec[i] = params\_r(i);  
253 : std::vector vars\_vec;  
254 : std::vector params\_i\_vec;  
255 : write\_array(base\_rng, params\_r\_vec, params\_i\_vec, vars\_vec, include\_tparams, include\_gqs, pstream);  
256 : vars.resize(vars\_vec.size());  
257 : for (int i = 0; i \< vars.size(); ++i)  
258 : vars(i) = vars\_vec[i];  
259 : }  
260 :  
261 : static std::string model\_name() {  
262 : return “model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1”;  
263 : }  
264 :  
265 :  
266 : void constrained\_param\_names(std::vectorstd::string& param\_names\_\_,  
267 : bool include\_tparams\_\_ = true,  
268 : bool include\_gqs\_\_ = true) const {  
269 : std::stringstream param\_name\_stream\_\_;  
270 : param\_name\_stream\_\_.str(std::string());  
271 : param\_name\_stream\_\_ \<\< “y”;  
272 : param\_names\_\_.push\_back(param\_name\_stream\_\_.str());  
273 :  
274 : if (!include\_gqs\_\_ && !include\_tparams\_\_) return;  
275 :  
276 : if (include\_tparams\_\_) {  
277 : }  
278 :  
279 : if (!include\_gqs\_\_) return;  
280 : }  
281 :  
282 :  
283 : void unconstrained\_param\_names(std::vectorstd::string& param\_names\_\_,  
284 : bool include\_tparams\_\_ = true,  
285 : bool include\_gqs\_\_ = true) const {  
286 : std::stringstream param\_name\_stream\_\_;  
287 : param\_name\_stream\_\_.str(std::string());  
288 : param\_name\_stream\_\_ \<\< “y”;  
289 : param\_names\_\_.push\_back(param\_name\_stream\_\_.str());  
290 :  
291 : if (!include\_gqs\_\_ && !include\_tparams\_\_) return;  
292 :  
293 : if (include\_tparams\_\_) {  
294 : }  
295 :  
296 : if (!include\_gqs\_\_) return;  
297 : }  
298 :  
299 : }; // model  
300 :  
301 : } // namespace  
302 :  
303 : typedef model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1 stan\_model;  
304 :  
305 : /**  
306 : \* Define Rcpp Module to expose stan\_fit’s functions to R.  
307 : \*/  
308 : RCPP\_MODULE(stan\_fit4model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_mod){  
309 : Rcpp::class\_\<rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1,  
310 : boost::random::ecuyer1988\> \>(“stan\_fit4model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1”)  
311 : // .constructorRcpp::List()  
312 : .constructor\<SEXP, SEXP, SEXP\>()  
313 : // .constructor\<SEXP, SEXP\>()  
314 : .method(“call\_sampler”,  
315 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::call\_sampler)  
316 : .method(“param\_names”,  
317 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::param\_names)  
318 : .method(“param\_names\_oi”,  
319 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::param\_names\_oi)  
320 : .method(“param\_fnames\_oi”,  
321 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::param\_fnames\_oi)  
322 : .method(“param\_dims”,  
323 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::param\_dims)  
324 : .method(“param\_dims\_oi”,  
325 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::param\_dims\_oi)  
326 : .method(“update\_param\_oi”,  
327 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::update\_param\_oi)  
328 : .method(“param\_oi\_tidx”,  
329 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::param\_oi\_tidx)  
330 : .method(“grad\_log\_prob”,  
331 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::grad\_log\_prob)  
332 : .method(“log\_prob”,  
333 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::log\_prob)  
334 : .method(“unconstrain\_pars”,  
335 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::unconstrain\_pars)  
336 : .method(“constrain\_pars”,  
337 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::constrain\_pars)  
338 : .method(“num\_pars\_unconstrained”,  
339 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::num\_pars\_unconstrained)  
340 : .method(“unconstrained\_param\_names”,  
341 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::unconstrained\_param\_names)  
342 : .method(“constrained\_param\_names”,  
343 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::constrained\_param\_names)  
344 : .method(“standalone\_gqs”,  
345 : &rstan::stan\_fit\<model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1\_namespace::model2a80454e5ad0\_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988\>::standalone\_gqs)  
346 : ;  
347 : }  
348 :  
349 : // declarations  
350 : extern “C” {  
351 : SEXP file2a80750e7690( ) ;  
352 : }  
353 :  
354 : // definition  
355 :  
356 : SEXP file2a80750e7690( ){  
357 : return Rcpp::wrap(“73fc79f8b1915e8208c736914c86d1a1”);  
358 : }  
359 :  
360 :  
Compilation argument:  
C:/Program Files/R/R-40~1.0/bin/x64/R CMD SHLIB file2a80750e7690.cpp 2\> file2a80750e7690.cpp.err.txt  
Error in file(con, “r”) : cannot open the connection  
In addition: Warning message:  
In file(con, “r”) :  
cannot open file ‘file2a80750e7690.cpp.err.txt’: No such file or directory

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [April 28, 2020, 5:44am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/12 "2020-04-28T05:44:17Z")

</div>

> [@RR\_Stan](#):
>
> WARNING: Rtools is required to build R packages, but the version of Rtools previously installed in C:/rtools40 has been deleted.

Possibly relevant

---

<div class="post-metadata">

**Author:** ![RR\_Stan](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@RR\_Stan](https://discourse.mc-stan.org/u/RR_Stan)\
**Post date:** [April 28, 2020, 6:14am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/13 "2020-04-28T06:14:29Z")

</div>

Yes I noticed that so I reinstalled rtools40 again. Got the same error. Are you aware of any solution for this? Currently rtools40 is installed under C:/rtools40?

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [April 28, 2020, 6:20am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/14 "2020-04-28T06:20:17Z")

</div>

You may have some residuals of old Rtools left somewhere. Possible locations are you PATH and the .Rprofile file in your documents folder. I had a same problem at some point and removing traces from the old Rtools in these places helped.

---

<div class="post-metadata">

**Author:** ![RR\_Stan](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@RR\_Stan](https://discourse.mc-stan.org/u/RR_Stan)\
**Post date:** [April 28, 2020, 7:15am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/15 "2020-04-28T07:15:48Z")

</div>

Thanks for your tips.  
For Path, the results are:  
[1] “C:\rtools40\usr\bin;C:\Program Files\R\R-4.0.0\bin\x64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\Dell Data Protection\Encryption\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files\SASHome\SASFoundation\9.4\ets\sasexe;C:\Program Files\SASHome\Secure\ccme4;C:\Program Files (x86)\Webex\Plugins;C:\Users\fur\AppData\Local\Microsoft\WindowsApps;”

- Anything abnormal? ( I don’t see any but my knowledge on this is very limited.)

And I run “file.edit(”~/.Rprofile")" , the file is completely empty, maybe because I just re-installed everything? Is it the correct way to edit ~/.Rprofile?

Thanks!

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [April 28, 2020, 7:30am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/16 "2020-04-28T07:30:04Z")

</div>

Try to remove the rtools40 stuff from your PATH. If you followed the native install instructions or rtools, this shouldn’t be required.

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [April 28, 2020, 7:57am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/17 "2020-04-28T07:57:07Z")

</div>

I had issues with R using the old Rtools because I had set the `BINPREF` environment variable to the old installation.

If you call `Sys.getenv("BINPREF")` and the output isn’t `""`, then that could be the issue

---

<div class="post-metadata">

**Author:** ![Stephen\_Martin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stephen_martin/32/7879_2.png) [@Stephen\_Martin](https://discourse.mc-stan.org/u/Stephen_Martin)\
**Post date:** [April 28, 2020, 9:03am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/18 "2020-04-28T09:03:52Z")

</div>

The rtools40 [instructions](https://cran.r-project.org/bin/windows/Rtools/) include: `writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")`

I got the same ‘rtools has been deleted’ warning before I ran that.

I’d recommend just starting with a clean Renviron and Makevars.win, then run that line above, and see whether it works.

---

<div class="post-metadata">

**Author:** ![mtsaari](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mtsaari](https://discourse.mc-stan.org/u/mtsaari)\
**Post date:** [April 28, 2020, 4:58pm UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/19 "2020-04-28T16:58:04Z")

</div>

I had similar error messages after installing R 4.0. Installing Rcpp, RcppEigen and rstan together from source worked for me.  
`install.packages(c("Rcpp", "RcppEigen", "rstan"), type = "source")`

---

<div class="post-metadata">

**Author:** ![toschwo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/toschwo/32/7894_2.png) [@toschwo](https://discourse.mc-stan.org/u/toschwo)\
**Post date:** [May 3, 2020, 5:03am UTC](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615/20 "2020-05-03T05:03:42Z")

</div>

Got this same issue and

> Sys.getenv(“BINPREF”)  
> [1] “C:/Rtools/mingw\_$(WIN)/bin/”

What should I do? Can you provide code to set the BINPREF environment variable to the new Rtools installation? Thanks so much!

[Next page](https://discourse.mc-stan.org/t/error-cannot-allocate-vector-of-size-17348-7-gb/14615.md?page=2)
