A fix for the memory leak in !41495 (merged).
@kbelobor can you verify this works as you expect.
cc @wwalko