stan-dev/stan — pull request #1168 by bob-carpenter (2014-12-11 20:09:02+00:00)
Title: Bugfix/feature 1160 memory leak

#### Summary:

Rewrote `agrad::preallocated_gradients` to use memory arena rather than `std::vector`; added templated array allocator to `memory::stack_alloc`

#### Intended Effect:

Plug memory leak and provide an easy way to allocate arrays in `vari` instances in the future.

#### How to Verify:

1. Run the harmonic oscillator example, which used to leak and now doesn't (fastest way to see it is with both being variables). The examples are in the manual directory, `src/docs/stan-reference/programs/ode/sho/`.

2. Run the unit tes4t for the new `stack_alloc` method, which basically just shows how to use it and that it does indeed allocate.

#### Side Effects:

None.

#### Documentation:

No user-facing doc.

#### Reviewer Suggestions:

I'd suggest Rob, but just about anyone can do it who's familiar with the autodiff memory management (Marcus, Michael, and Daniel, at least).