@wds15 and I have been unable to figure out why clang++
incorrectly compiles a branch of RStan that works with the master branches of Stan Math and Stan Libraries. The usual behavior of Stan is that after the model is compiled, sampling will use essentially a constant amount of RAM, which is what happens when everything is compiled with g++
(at least on Linux). However, if everything is compiled with clang++
, sampling will keep slowly consuming more RAM until you run out, even though recover_memory
is getting called and even though none of the tools we have used so far has found evidence of a memory leak.
There is a wiki page with various peopleās experience at
and a mostly clean C++ file that can be compiled but will eat all your RAM if you do MCMC mvn_orange.cpp (31.4 KB) .
If there is someone who knows how to use Instruments that comes with Xcode, that might be helpful. Or someone with Linux that knows how to work with objdump
or similar.
Unfortunately, we donāt have any good alternatives right now. The RStan on CRAN (which does header-only compilation, except for SUNDIALS) wonāt work with Catalina, but the default compiler for Catalina is clang++ so non-trivial models will exhaust the RAM if do the CRTP pattern. Also, RStudio Cloud hasnāt worked with RStan on CRAN for a couple of releases because we canāt do header-only compilation within the 1GB limit users are given. We could get under that if do CRTP but only if the userās model is compiled with clang++
, which would then exceed the 1GB limit when sampling is called.