Automatic Differentiation
 
Loading...
Searching...
No Matches
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
9namespace stan {
10namespace math {
11
18static inline void recover_memory() {
19 if (!empty_nested()) {
20 throw std::logic_error(
21 "empty_nested() must be true"
22 " before calling recover_memory()");
23 }
27 delete x;
28 }
31}
32
33} // namespace math
34} // namespace stan
35#endif
void recover_all()
Recover all the memory used by the stack allocator.
static bool empty_nested()
Return true if there is no nested autodiff being executed.
static void recover_memory()
Recover memory used for all variables for reuse.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
static thread_local AutodiffStackStorage * instance_