Fix retain cycle(s) in encoder implementation
This patch was authored by @petrpavlik and released by @0xTim.
This PR addresses issue #215 and server as an alternative of PR #216, that somehow got stuck in it's efforts of being merged in.
I've done 2 things to discover the issue and confirm the fix
- Xcode would show a bunch of memory leaks when using it's memory graph debugger, those are gone after the changes introduced in this PR
- I've switched https://swiftpack.co, which uses leaf heavily, to using my fork with this fix. The heroku graph bellow shows significantly lower memory consumption and does not seem to be crashing, though I still do do seem to have memory leaks somewhere in the codebase.