Stan Math Library  2.20.0
reverse mode automatic differentiation
recover_memory.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_CORE_RECOVER_MEMORY_HPP
2 #define STAN_MATH_REV_CORE_RECOVER_MEMORY_HPP
3 
7 #include <stdexcept>
8 
9 namespace stan {
10 namespace math {
11 
18 static inline void recover_memory() {
19  if (!empty_nested())
20  throw std::logic_error(
21  "empty_nested() must be true"
22  " before calling recover_memory()");
25  for (auto &x : ChainableStack::instance_->var_alloc_stack_) {
26  delete x;
27  }
30 }
31 
32 } // namespace math
33 } // namespace stan
34 #endif
static bool empty_nested()
Return true if there is no nested autodiff being executed.
static STAN_THREADS_DEF AutodiffStackStorage * instance_
void recover_all()
Recover all the memory used by the stack allocator.
static void recover_memory()
Recover memory used for all variables for reuse.

     [ Stan Home Page ] © 2011–2018, Stan Development Team.