Netflix/RxJava — pull request #712 by benjchristensen (2013-12-31 19:07:20+00:00)
Title: Fix Scheduler Memory Leaks

The `NewThreadScheduler`, `CurrentThreadScheduler` and `ExecutorScheduler` all had memory leaks when doing recursion with the `Func2` method signature. This pull request fixes that along with improving the unit test coverage.

The fix involved treating "outer" and "inner" schedulers differently, with "inner" being the place where recursion happens.

The memory behavior can be tested using `TestRecursionMemoryUsage`.

This fixes the problems reported in https://github.com/Netflix/RxJava/pull/643 and https://github.com/Netflix/RxJava/pull/648 but does not change the `Scheduler` or `Subscription` interfaces or public implementation details.