wwt/SwiftCurrent

Memory Leak on Workflows

Tyler-Keith-Thompson opened this issue · 0 comments

Describe the bug

We're leaking memory every time a workflow is launched and followed.

To Reproduce

Steps to reproduce the behavior:

  1. Create a workflow (ideally that autocompletes) for example a workflow that proceeds to the next item on viewDidLoad after 1 second.
  2. Launch that workflow multiple times
  3. Make sure the workflow has called onFinish. Bonus points: call abandon on it, NOTE: You should not have to in order to solve this problem, and calling abandon exposed an additional bug.
  4. Open the memory graph and cry, because the _WorkflowItems got retained when they should not have.

Expected behavior

A workflow should not create retain cycles, it's fine that it retains while executing, but when it is abandoned or when the same workflow is launched again it is reasonable that there aren't retain cycles.

NOTE: The library clears instances when you launch a Workflow. Is that behavior correct, or is that a bad assumption? It probably has limitations if a user launches the same instance of a workflow multiple times and expects it to just be duplicated. That's an odd thing for a user to expect, but the library does not support it currently. It assumes every call to launch means it can clear memory of all known instances.