PerlDancer/Dancer2 — pull request #662 by veryrusty (2014-08-15 11:08:51+00:00)
Title: Bugfix: remove circular refs

@xsawyerx and @mickeyn noted as part of the untangling of the context object that there were circular memory refs in the App object that may lead to memory leaks.

There were two common causes of circular memory refs:
* Route handlers require a reference to an app they are added to, but the attribute wasn't declared as a weak ref; and
* a closure around the app coderef in the `after` that flushes sessions for the app.

This Pr uses `Test::Memory::Cycle` to verify that no cyclic memory references remain in an app or the Runner (which adds a testing dependency). The `Role::Handler->app` attribute is now declared to be a weak ref (plus some code cleanup in App when they are created), and we generate a weakened copy of an App before closing over that copy in the default `after` hook code.

Resolves #610.